Skip to main content

It's a robust webserver (http/ws) for hosting htag apps on the web (a process by user)

Project description

htagweb

Test

Package version

This "htagweb" module is the official way to expose htag's apps on the web.

Important note On the web, the server can handle many clients : so, it's not possible to handle each tag instances per user. SO there are 1 limitation compared to classical htag runners which comes with htag.

  • there can be only one managed instance of a htag class, per user (it's the case in classical runners too)
  • and tag instances doesn't live as long as the runner lives (when you hit F5, it will be destroyed/recreated). So, keeping states must be done thru the tag.state / tag.root.state (which is the session of the user).

So developping a htag app which work the same on desktop and on the web, should manage its states in tag.state / tag.root.state ;-)

Features

  • based on starlette
  • multiple ways to handle sessions (file, mem, etc ...)
  • compatible with uvloop !!!
  • compatible with multiple gunicorn/uvicorn/webworkers !!!
  • compatible with tag.update()
  • works on gnu/linux, ios or windows !
  • real starlette session available (in tag.state, and starlette request.session)
  • compatible with oauth2 authent ( authlib )
  • 'parano mode' (can aes encrypt all communications between client & server ... to avoid mitm'proxies on ws exchanges)

Roadmap / futur

priority :

  • ci/cd test python>3.7 with shared_memory_dict
  • unittests on sessions.memory (won't work now)
  • better unittests on usot

futur:

  • ? replace starlette by fastapi ?
  • the double rendering (double init creation) is not ideal. But great for SEO bots. Perhaps I could find a better way (and let only one rendering, but how ?!) ?!
  • more unittests !!!
  • better logging !!!

Examples

A "hello world" could be :

from htag import Tag

class App(Tag.div):
    def init(self):
        self+= "hello world"

from htagweb import AppServer
AppServer( App ).run()

or, with gunicorn (in a server.py file, as following):

from htag import Tag

class App(Tag.div):
    def init(self):
        self+= "hello world"

from htagweb import AppServer
app=AppServer( App )

and run server :

gunicorn -w 4 -k uvicorn.workers.UvicornH11Worker -b localhost:8000 --preload server:app

See a more advanced example in examples folder

python3 examples/main.py

Standalone module can act as server

The module can act as "development server", providing a way to quickly run any htag class in a browser. And let you browse current *.py files in a browser.

$ python3 -m htagweb

htagweb will look for an "index:App" (a file index.py (wich contains a htag.Tag subclass 'App').), and if it can't found it : expose its own htag app to let user browse pythons files in the browser (/!\)

or

$ python3 -m htagweb main:App

if you want to point the "/" (home path) to a file main.py (wich contains a htag.Tag subclass 'App').

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

htagweb-0.8.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

htagweb-0.8.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file htagweb-0.8.1.tar.gz.

File metadata

  • Download URL: htagweb-0.8.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.2 Linux/5.15.0-1041-azure

File hashes

Hashes for htagweb-0.8.1.tar.gz
Algorithm Hash digest
SHA256 19b652454fe541a06da2db9924fbdc2992c8d8d66d823c1e854e5ed39b8e8a4d
MD5 93e6c45caadbb92e1f9373417eebb685
BLAKE2b-256 1ad6347398814678bbf67235cba9a3e4f4e29d211b519674a15b9f7d78e3e0a7

See more details on using hashes here.

File details

Details for the file htagweb-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: htagweb-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.2 Linux/5.15.0-1041-azure

File hashes

Hashes for htagweb-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8fc4a8a72b32563b1b4a31999b928fcdfec2456ba79ddde1cbf60ffa22c22fb3
MD5 f1cb255d4379efd988f44cb80590dce0
BLAKE2b-256 f508bcde31e64e5dac43224559e5f77d9abfe361bf1d9a62a11695abab1ce8ad

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