A simple way to host web server bundled with websocket to send and receive live data, from client to server, and pass live HTML changes from server to client without having to refresh the page.
Project description
dynamicWebsite v1.4.3
pip install dynamicWebsite --upgrade
A simple way to host web server bundled with websocket to send and receive live data, from client to server, and pass live HTML changes from server to client without having to refresh the page."
To install:
pip install dynamicWebsite --upgrade
pip3 install dynamicWebsite --upgrade
python -m pip install dynamicWebsite --upgrade
python3 -m pip install dynamicWebsite --upgrade
Using this program is as simple as:
from dynamicWebsite import *
def process_form(viewerObj: BaseViewer, form: dict):
if form.get("PURPOSE") == "SHOW_IMAGE1":
initial = f'''<img src="" alt="IMG1"></img>'''
viewerObj.queueTurboAction(initial, "mainDiv", turboApp.methods.update)
elif form.get("PURPOSE") == "SHOW_IMAGE2":
initial = f'''<img src="" alt="IMG2"></img>'''
viewerObj.queueTurboAction(initial, "mainDiv", turboApp.methods.update)
def newVisitor(viewerObj: BaseViewer):
initial = f'''
<form onsubmit="return submit_ws(this)">
{viewerObj.addCSRF("SHOW_IMAGE1")}
<input type="text" name="username"><br>
<input type="password" name="password"><br>
<input type="file" name="ball" multiple><br>
<button type="submit">Search</button>
</form>
'''
viewerObj.queueTurboAction(initial, "mainDiv", turboApp.methods.update)
def visitorLeft(viewerObj: BaseViewer):
print(f"Visitor Left: {viewerObj.viewerID}")
extraHeads = ""
fernetKey = 'JJafcmKx6WRzZKhC8THl7tfXce2BVdYEntGHPJNFwSU='
bodyBase = """<body><div id="mainDiv"></div></body>"""
title = "Song Player"
resetOnDisconnect = False
baseApp, turboApp = createApps(process_form, newVisitor, visitorLeft, "Song Player", "/", fernetKey, extraHeads, bodyBase, title, resetOnDisconnect)
baseApp.run("0.0.0.0", 5000)
Future implementations:
- Adding ability to add classes and other HTML arguments to elements created
- Adding templates for various uses
This project is always open to suggestions and feature requests.
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
dynamicwebsite-1.4.3.tar.gz
(11.4 kB
view details)
Built Distribution
File details
Details for the file dynamicwebsite-1.4.3.tar.gz
.
File metadata
- Download URL: dynamicwebsite-1.4.3.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec19f78250ae13e5e0810f65ecae065b1fa2eec47c6f82565f0388f0df6ee6da |
|
MD5 | 008a80e9bb3bde039e0562527655fcd5 |
|
BLAKE2b-256 | c1bb2e12f4b5cc3e33d86a09a4e2dc27d3c306a45dfc510feb1b235f49f7fc05 |
File details
Details for the file dynamicWebsite-1.4.3-py3-none-any.whl
.
File metadata
- Download URL: dynamicWebsite-1.4.3-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6488ea1672745ea6d3ada21b52a0630cc31bcd3147f3ef2b70d84cb0add171ac |
|
MD5 | 5bb14683b2b9e3216ba8fa5a96399e09 |
|
BLAKE2b-256 | 167582dad5eedb5bd101b9df45d623a4cdba55be9948fc939d60e91b54c08c0e |