Skip to main content

gladius

Downloads Supported Versions License: 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. These developers often blend Python on the server with traditional JavaScript/CSS tools for frontend UI—Gladius simplifies this workflow by enabling Python-driven UI development, reducing context-switching between languages.

For traditional frontend developers, Gladius offers a comfortable transition by exposing all standard Web APIs available in browsers. This ensures compatibility with existing NPM packages (from npmjs), allowing seamless integration of JavaScript 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

pip install gladius[all]

Hello World

Create app.py file with content:

from aiohttp import web
from gladius.starter import create_aiohttp_app

# required npm packages
npm_packages = {
    '@picocss/pico': ['css/pico.css'],
    'nprogress': ['nprogress.js', 'nprogress.css'],
}

# client-side click handler
def ready():
    from pyscript import when
    from pyscript.web import page
    from pyscript.js_modules.nprogress import default as NProgress

    btn = page['#hello-button'][0]  # get server-created button
    clicked = 0                     # track clicks

    @when('click', btn)
    def on_click(event):
        global clicked
        NProgress.start()
        clicked += 1
        btn.innerText = f'Clicked {clicked} time{"s" if clicked !=1 else ""}!'
        NProgress.done()

# create simple aiohttp web server
g, page, app = create_aiohttp_app(
    npm_packages=npm_packages, # type: ignore
    use_pyscript=True,
    use_micropython=True,
    ready=ready,
)

# server-side structure
with page:
    with g.body(x_data=None):
        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__':
    web.run_app(app, host='0.0.0.0', port=5000)

Run python app with simple server in background:

python -B app.py

Or, in case you want to rebuild on code change:

python -B -u -m gunicorn --reload --bind '0.0.0.0:5000' --timeout 300 --workers 1 --worker-class aiohttp.GunicornWebWorker 'app:app'

Metadata

Release files for gladius 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gladius 0.3.5
File Size Uploaded
gladius-0.3.5.tar.gz 38.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gladius 0.3.5
File Interpreter ABI Platform
gladius-0.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 75.1 kB

Release files / gladius-0.3.5.tar.gz

Download URL gladius-0.3.5.tar.gz
Size 38.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3fefeb9b750c5eaefc2a4c935374b45ce1c5c563e48a7457f56ebbc57913a18d
BLAKE2b-256 checksum
How to use checksums
a28c76ec7e658e8912961d12bd353058d513882cfa43feb20c1676bba3fb57cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.9 Linux/6.13.7-arch1-1

Release files / gladius-0.3.5-py3-none-any.whl

Download URL gladius-0.3.5-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3715749b3a6686831aa94ef7db8caf23019116c3c1af19fa0e6b52e33f87851
BLAKE2b-256 checksum
How to use checksums
37483072a3e1408a2eb1246b1f36784794674e1ef2a7ebc3e68aa263e0652ac1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.9 Linux/6.13.7-arch1-1

Release history Release notifications | RSS feed

This release

0.3.5 This release

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page