baseweb
A Pythonic base for building interactive web applications
Async/Quart Support
Version 0.5.0+ uses Quart (async) instead of Flask (sync).
- All route handlers must be
asyncfunctions request.get_json()must be awaitedrender_template()must be awaited- WebSocket uses python-socketio (ASGI mode)
For legacy Flask support: Use baseweb<0.5.0 or see the Migration Guide.
Installation
pip install baseweb
Quick Start
# Install baseweb and an ASGI server
pip install baseweb gunicorn uvicorn
# Run the stock baseweb application (with WebSocket support)
gunicorn -w 1 -k uvicorn.workers.UvicornWorker "baseweb:server._asgi_app"
Visit http://localhost:8000 to see baseweb in action.
Features
| Feature | Description |
|---|---|
| Quart Integration | Pre-configured Quart application with async support |
| Vue.js + Vuetify | Modern frontend stack ready to use |
| REST API | Built-in Resource class for REST APIs |
| WebSocket Support | python-socketio with ASGI for real-time communication |
| Authentication | Built-in authentication/authorization hooks (HTTP + WebSocket) |
| PWA Support | Progressive Web App capabilities |
Usage
Basic Application
from baseweb import Baseweb
app = Baseweb(__name__)
# ASGI entry point for running with uvicorn/gunicorn
asgi_app = app._asgi_app
Run with: gunicorn -k uvicorn.workers.UvicornWorker "myapp:asgi_app"
With REST API
from baseweb import Baseweb, Resource
app = Baseweb(__name__)
class MyResource(Resource):
async def get(self):
return {"message": "Hello, async world!"}
async def post(self):
data = await request.get_json()
return {"received": data}
app.add_resource(MyResource, "/api/my-resource")
With WebSockets
from baseweb import Baseweb
app = Baseweb(__name__)
@app.socketio.on("connect")
async def handle_connect(sid, environ):
await app.socketio.emit("connected", {"data": "Connected"})
@app.socketio.on("message")
async def handle_message(sid, data):
# Echo back to the sender
return {"echo": data}
With Authentication
from baseweb import Baseweb
app = Baseweb(__name__)
def authenticator(scope, request, *args, **kwargs):
# Validate request/auth and return True/False
return True
app.authenticator = authenticator
# Use @app.authenticated(scope) decorator for protected handlers
@app.socketio.on("private_event")
@app.authenticated("app.events.private")
async def handle_private(sid, data):
return {"status": "authorized"}
For more examples, see the documentation.
Legacy Flask Support
For Flask-based applications (pre-0.5.0):
- Pin to legacy version: Use
baseweb<0.5.0for Flask/Flask-SocketIO support - Migrate to Quart: Follow the Migration Guide
The baseweb-demo repository has a legacy tag pointing to the last Flask-compatible commit.
Documentation
Full documentation available at Read the Docs:
Development
Prerequisites
- Python 3.10, 3.11, or 3.12
- uv for dependency management
Setup
git clone https://github.com/christophevg/baseweb.git
cd baseweb
uv sync --all-extras
Testing
# Run tests
uv run pytest
# Run linting
uv run ruff check src tests
# Or use Makefile
make test # run tests
make check # run all checks
Multi-Version Testing
# Install all Python versions (one-time setup)
make install-pythons
# Run tests on all versions
uv run tox
Project Structure
| Directory | Purpose |
|---|---|
src/baseweb/ |
Main package source |
tests/ |
Test suite |
docs/ |
Sphinx documentation |
Contributing
See Contributing for guidelines.
Changelog
See CHANGELOG.md for version history. For released versions, see GitHub Releases.
License
Metadata
Release files for baseweb 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| baseweb-0.6.0.tar.gz | 6.9 MB | Without provenance | Details for baseweb-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| baseweb-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for baseweb-0.6.0-py3-none-any.whl |
Total release size: 10.4 MB
Release files / baseweb-0.6.0.tar.gz
| Download URL | baseweb-0.6.0.tar.gz |
|---|---|
| Size | 6.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b77812d4bedcfc5967030612c9ab8dc0f0f37ee8c84a92d4bb6681f2f06f53e8
|
|
BLAKE2b-256 checksum How to use checksums |
ecbaaa0d5e69a03657058d2554a58465d6d95d08638e0709e64f79acf7e697d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / baseweb-0.6.0-py3-none-any.whl
| Download URL | baseweb-0.6.0-py3-none-any.whl |
|---|---|
| Size | 3.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d4b9e459c5e00b1b5badd302b2f799f5eb1757155704683ff14a044a325e51e
|
|
BLAKE2b-256 checksum How to use checksums |
e6ace84665bcd216749b8b12abb6cef14318bf3c2fefbaaf4a6b9fcb5e0b6bf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for baseweb 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.