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

Todo App example

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 !

Edit with Gitpod

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 flask_socketio_lit_html/dependencies/ && yarn && yarn build && cd ../..

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.6.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

flask_socketio_lit_html-0.1.6-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask-socketio-lit-html-0.1.6.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.7.1 Linux/4.15.0-1028-gcp

File hashes

Hashes for flask-socketio-lit-html-0.1.6.tar.gz
Algorithm Hash digest
SHA256 cc5193299897630ceb277325ab64e3b2a6ab00346c53d2ace27f4c62056a3ecf
MD5 e01b8c57742c5b6fe47eeeb919a43331
BLAKE2b-256 06d279cfe9dd9f5c00c92a201856ebfd8e00a31ac81b68d2dc069624f75752f9

See more details on using hashes here.

File details

Details for the file flask_socketio_lit_html-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_socketio_lit_html-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f738c72c4a4c6ac26a7c12671f12393292142c4c2b5c972bda2fc55bf7a05c0f
MD5 efc00e0ecea19505635da0b79df52b72
BLAKE2b-256 ed6c83b08d46f29abec5cba332c43f9267ed13e8d66b1b6711e5b0491b42b50d

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