Skip to main content

Full-stack web apps in Python

Project description

gladius

Downloads Supported Versions License: MIT

Gladius aka "gladius" is a full-stack web framework facilitating web application development exclusively in pure Python, eliminating the need for HTML, CSS, or JavaScript. It is built for those who prefer to use Python, providing access to features typically found in modern web frameworks.

Gladius integrates basic HTML5 elements, TailwindCSS styling, and DaisyUI components, built on top of aiohttp, uvloop, and HTMX, allowing developers to concentrate on application logic and functionality, while the framework handles the UI/UX aspects. It also incorporates client-side routing typical of Single Page Applications (SPAs), promoting smoother transitions and increased interactivity.

In essence, gladius offers a simplified and cohesive development experience, making it a practical choice for developers seeking a Python-centric approach to both frontend and backend development.

Hello World

from random import randint

from gladius import Gladius, Component, EventRequest
from gladius.daisyui import DaisyUI

# glados daisyui
g = Gladius()
ui = DaisyUI(g)

# callbacks
async def hello_button_click(button: Component, req: EventRequest):
    hello_text.content = f'Hello {randint(0, 100)}'

async def world_button_click(button: Component, req: EventRequest):
    world_text.content = f'World {randint(0, 100)}'

# page
page = ui.Page(title='Hello world', class_='p-10')
page.add(vflex := ui.VFlex())

# top cards
vflex.add(card := ui.Card())
card.add(hello_text := ui.Text('Hello'))

vflex.add(card := ui.Card())
card.add(world_text := ui.Text('World'))

# buttons
vflex.add(hflex := ui.Flex())
hflex.add(join := ui.Join())
join.add(button := ui.Button(class_='btn btn-primary', onclick=hello_button_click).add('Hello'))
join.add(button := ui.Button(class_='btn btn-secondary', onclick=world_button_click).add('World'))

# router
g.route('/', page)
app = g.get_app()

if __name__ == '__main__':
    g.run_app(host='0.0.0.0', port=5000)

Install

pip install gladius

Run Examples

git clone https://github.com/mtasic85/gladius.git
cd gladius
python -m venv venv
source venv/bin/activate
pip install

Hello world:

gunicorn examples.hello_world_0:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

Multi-page:

gunicorn examples.multi_page_0:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

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

gladius-0.1.1.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gladius-0.1.1-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file gladius-0.1.1.tar.gz.

File metadata

  • Download URL: gladius-0.1.1.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.4-arch2-1

File hashes

Hashes for gladius-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1c45b42112bdd6f3e7682eb11b4d2c124da9a0f0232a22e66afae05aa2e4eda9
MD5 662c60892a43bf2b5bd5734186bbcc7c
BLAKE2b-256 71682f26d5d6e2171ec982328d0cf7c5872aaedc0d06cabc4ecb08c99291cdf4

See more details on using hashes here.

File details

Details for the file gladius-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gladius-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.4-arch2-1

File hashes

Hashes for gladius-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d36166914a14ae199b94297d61400394b46fa5b1151623cbfb729f2e7804cc21
MD5 f29a1171ad4f082058145af4cc8b4e87
BLAKE2b-256 a993e2d5e1c372e1aa5e09039d555ea30c5052b2efcf26f502a2f974ce8eca15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page