How to integrate P5JS with Flask-SocketIO

Github Repo Main codes Server: from shopyo.api.module import ModuleHelp from flask_socketio import SocketIO, join_room, leave_room, emit from init import socketio mhelp = ModuleHelp(__file__, __name__) globals()[mhelp.blueprint_str] = mhelp.blueprint module_blueprint = globals()[mhelp.blueprint_str] @module_blueprint.route(“/”) def index(): return mhelp.render(‘index.html’) @socketio.on(‘mouse’)# , namespace=’/chat’) def mouse(data, methods=[‘GET’, ‘POST’]): # print(data) emit(‘mouse’, data, broadcast=True) Client <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″ /> …

How to integrate P5JS with Flask-SocketIO Read More »

Notes of Get your resources faster, with importlib.resources by Barry Warsaw

Talk notes thepkg/ # is a package since has __init__.py __init__.py a.py b.py data/ sample.dat You need to get data files (templates, certifs etc) from your package You do import thepkg from pathlib import Path pkg = Path.(thepkg.__file__).parent path = pkg / ‘data’ / ‘sample.dat’ Problem as __file__ not necessarily a real file on system …

Notes of Get your resources faster, with importlib.resources by Barry Warsaw Read More »

How to Integrate Tinymce 5 with Flask (with csrf)

This article shows how to integrate Tinymce 5 with Flask even including csrf protection! Text area <textarea id=”content”></textarea> Tinymce <script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.10.2/tinymce.min.js”></script> <script type=”text/javascript”> tinymce.init({ selector: ‘#content’, plugins: [ ‘advlist autolink link image imagetools lists charmap print preview hr anchor pagebreak spellchecker’, ‘searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking’, ‘save table contextmenu directionality …

How to Integrate Tinymce 5 with Flask (with csrf) Read More »