Skip to main content

Simple Webcomponents with flask

Project description

ForTheBadge uses-badges ForTheBadge uses-badges ForTheBadge uses-badges

Version: Alpha License: MIT Pypi version ReadTheDocs Travis (.org) codecov Code Climate maintainability

Flask-Socket.IO-lit-html

Webcomponents with Flask and SocketIO Quick Start on documentation

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.register("/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 !

Edit with Gitpod

Updating autodoc

cd docs && sphinx-apidoc -o source/ ../flask_socketio_lit_html

Build package

poetry build

Running browser tests

cd tests ; yarn test

Webcomponent's shadow root are disabled when running testcafe (for selecting components)

Any questions ?

Slack Status

Join the community on Spectrum

External resources

Learn webcomponents and lit-element on dev.to

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-socketio-lit-html-0.1.1rc1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file flask-socketio-lit-html-0.1.1rc1.tar.gz.

File metadata

  • Download URL: flask-socketio-lit-html-0.1.1rc1.tar.gz
  • Upload date:
  • Size: 6.5 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

Hashes for flask-socketio-lit-html-0.1.1rc1.tar.gz
Algorithm Hash digest
SHA256 a513e121d09c5bc64441322938ffa8ca5d90aaa2055f39480fe22cd3681a8e23
MD5 1c974c5946f1f5fbe26e8d12764edb77
BLAKE2b-256 963fce3233a5cf2159368a0a0e53974c1d924b278f0bb12903c70c0e01d0f464

See more details on using hashes here.

File details

Details for the file flask_socketio_lit_html-0.1.1rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_socketio_lit_html-0.1.1rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 896892e97c601e2f0d6a3db1a77d8c8d8eafe2ee747099f2a5b34832719a1203
MD5 26722c79e6933880aeb168aece5deb3e
BLAKE2b-256 fac84f8fe00b7a219979a7a4f1cb594b4c0d08aac70bee9471f8a6bfa2ab26a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page