Flask-Socket.IO-lit-html
Webcomponents with Flask and SocketIO
Proof of concept project to use Webcomponents in Python Flask
- Generate a restful API (inspired from Flask-Restful)
- Update html on data changes through socketio (Inspired from Angular properties reflection)
- Based on the powerful lit-element library
- Progressive Web App compatibility: Component data cached in sessionStorage
Usage philosophy
Create user webcomponent from sqlalchemy design. GET and POST API on /user.
class User(db.Model):
username = db.Column(db.String(80), nullable=False)
blueprint = User.configure_blueprint("/user", "user-item", "User.html")
app.register_blueprint(blueprint)
Define the webcomponent view in a jinja template
{% block render %}
<strong>${ this.username }</strong>
{% endblock %}
Display the second user of your database with live update:
<script type="module" src="{{url_for('user-item.webcomponent')}}"></script>
<div> user 2: <user-item index=2 ></user-item></div>
This code represent the idea behind the module, look at app.py for a working example. Project may be modeled on wtforms-alchemy
Contribute : Pull requests are welcome !
Updating autodoc
cd docs && sphinx-apidoc -o source/ ../flask_socketio_lit_html
Build and test package
poetry build && pip3 install dist/flask_socketio_lit_html* --force-reinstall
Running browser tests
cd tests ; yarn ; yarn test
Webcomponent's shadow root are disabled when running testcafe (for selecting components)
Build lit-element with rollup.js
cd dependencies/ && yarn && yarn build ; cd ..
Any questions ?
External resources
Metadata
Release files for flask-socketio-lit-html 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask-socketio-lit-html-0.1.10.tar.gz | 31.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_socketio_lit_html-0.1.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.6 kB
Release files / flask-socketio-lit-html-0.1.10.tar.gz
| Download URL | flask-socketio-lit-html-0.1.10.tar.gz |
|---|---|
| Size | 31.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b03976caf0aa63b08fbd3fb10b18494109e3ec6aaf0b72fc46a32ff0325f138
|
|
BLAKE2b-256 checksum How to use checksums |
a31f4035776f36ebb4c1d089bedc1df5bc38436ec43bf35b4ac5d44b249ec697
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.8.10 Linux/5.8.0-1033-azure
|
Release files / flask_socketio_lit_html-0.1.10-py3-none-any.whl
| Download URL | flask_socketio_lit_html-0.1.10-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58f62352dfc63739217ea6e18c3567bc0d09713a9ea264f74c50458d6654b07d
|
|
BLAKE2b-256 checksum How to use checksums |
fd1006d5dcdfd9600da5270f246679861bee1f1b7486c85b05016610f72307a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.8.10 Linux/5.8.0-1033-azure
|