Simple Webcomponents with flask
Project description
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
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 test
Webcomponent's shadow root are disabled when running testcafe (for selecting components)
Build lit-element with rollup.js
cd flask_socketio_lit_html/dependencies/ && yarn && yarn build && cd ../..
Any questions ?
External resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask-socketio-lit-html-0.1.2.tar.gz
.
File metadata
- Download URL: flask-socketio-lit-html-0.1.2.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.1 Linux/4.15.0-1028-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0594a5f263b6350a20e49ac094605a5cf20ce7b0e6099453b1cc138b4995f5b |
|
MD5 | ca8c9f40f2eb7b62d748d576d8e697e0 |
|
BLAKE2b-256 | 60d6ced105f1e9e62afd40d93be6afc63c489c53b0a25635420d1fe8a32bbda3 |
File details
Details for the file flask_socketio_lit_html-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: flask_socketio_lit_html-0.1.2-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.1 Linux/4.15.0-1028-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9fcb026f038a1b4430b4e3e41fa9f9e501e5257e40cf27980463d60bd9f8b49 |
|
MD5 | bea9438102e437f938943c8e458ba4e5 |
|
BLAKE2b-256 | 76524c83dd816a6d265265d3c2d0372b0908687e2c1f1ab3a6b4be464d59b82f |