https://github.com/tangledgroup/gladius
Full-stack web apps in Python
https://github.com/tangledgroup/gladius
full-stack python web
Last synced: about 1 year ago
JSON representation
Full-stack web apps in Python
- Host: GitHub
- URL: https://github.com/tangledgroup/gladius
- Owner: tangledgroup
- License: mit
- Created: 2023-09-22T19:24:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-07T09:57:05.000Z (about 1 year ago)
- Last Synced: 2025-04-07T10:24:21.018Z (about 1 year ago)
- Topics: full-stack, python, web
- Language: Python
- Homepage:
- Size: 8.4 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gladius
[](https://pypistats.org/packages/gladius)
[](https://pypi.org/project/gladius)
[](https://opensource.org/licenses/MIT)

**Gladius** aka "gladius" is a library facilitating web application development exclusively in pure **Python**, eliminating the need for HTML, CSS, or JavaScript/TypeScript.
Built for developers who want to leverage Python across the entire stack, Gladius provides access to modern web framework features while mirroring patterns familiar to full-stack Python developers.
For traditional frontend developers, Gladius offers a comfortable transition by exposing all standard Web APIs available in browsers. This ensures compatibility with modern browsers and existing NPM packages (from npmjs), allowing seamless integration of JavaScript (and TypeScript) libraries when needed.
By unifying frontend and backend development under Python, Gladius delivers a cohesive, intuitive experience, ideal for developers seeking a Python, centric approach without sacrificing access to the broader web ecosystem.
## Install
```bash
pip install gladius[all]
```
## Hello World
Create `app.py` file with content:
```python
from gladius import create_app, run_app
# required npm packages
npm_packages = {
'@picocss/pico': ['css/pico.css'],
'nprogress': ['nprogress.js', 'nprogress.css'],
}
# client-side click handler
def ready():
from gladius import window, document, bind # type: ignore
NProgress = window.nprogress.default
btn = document.getElementById('hello-button') # get server-created button
clicked = 0 # track clicks # noqa
@bind(btn, 'click')
def on_click(event):
global clicked
NProgress.start()
clicked += 1 # type: ignore
btn.innerText = f'Clicked {clicked} time{"s" if clicked !=1 else ""}!'
NProgress.done()
# create simple aiohttp web server
g, page, app = create_app(
npm_packages=npm_packages, # type: ignore
ready=ready,
app_init_args={
'client_max_size': 1024 ** 3,
}
)
# server-side structure
with page:
with g.body():
with g.main(class_='container'):
g.h1('Gladius Demo')
g.button('Click me!', id='hello-button') # create button on server
# start application
if __name__ == '__main__':
run_app(app, host='0.0.0.0', port=5000)
```
Run python app with simple server in background:
```bash
python -B app.py
```
Or, in case you want to rebuild on code change:
```bash
python -B -u -m gunicorn --reload --bind '0.0.0.0:5000' --timeout 300 --workers 1 --worker-class aiohttp.GunicornWebWorker 'app:app'
```