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, Event
from gladius.daisyui import DaisyUI

g = Gladius()
d = DaisyUI(g)

# callbacks
async def hello_button_click(button: Component, event: Event):
    v: int = randint(0, 100)
    hello_card.data = f'Hello {v}'
    hello_button.data = f'Hello {v}'

async def world_button_click(button: Component, event: Event):
    v: int = randint(0, 100)
    world_card.data = f'World {v}'
    world_button.data = f'World {v}'

# page
page = d.Page(title='Hello world 0').add_class('p-10')
page.add(vflex := d.VFlex())

# cards
vflex.add(hello_card := d.Card('Hello'))
vflex.add(world_card := d.Card('World'))

# buttons
vflex.add(join := d.Join())
join.add(hello_button := d.Button('Hello', onclick=hello_button_click).add_class('btn-primary'))
join.add(world_button := d.Button('World', onclick=world_button_click).add_class('btn-secondary'))

# 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 .
# https://picocss.com
gunicorn examples.pico_0:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

# https://daisyui.com
gunicorn examples.daisyui_layout_0:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

# daisyui hello world 0
gunicorn examples.hello_world_0:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

# daisyui hello world 1
gunicorn examples.hello_world_1:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

# daisyui hello world 2
gunicorn examples.hello_world_1:app --reload --bind '0.0.0.0:5000' --worker-class aiohttp.GunicornWebWorker

# daisyui multi page 0
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.12.tar.gz (35.9 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.12-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gladius-0.1.12.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.5-arch1-1

File hashes

Hashes for gladius-0.1.12.tar.gz
Algorithm Hash digest
SHA256 35d5dd9555d470f56b37f19de0c9c3bb0f0a0742103f29d10b4e4bc7f66d7d4a
MD5 ead0679c4ee75012aa9eb43d406af630
BLAKE2b-256 776686742aff7f881aa3106a49fcba26f100f1038030129a776fae352d727983

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gladius-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 7d6fd83d687e6324fa2557d2f0caafa0624a3de0ce099fc7ece05e6d108ecf1f
MD5 cf11fa020244f1a23cef1c663195b685
BLAKE2b-256 a8ae082dded3c986447ab8e1cd8d12554e50260f2fa3b6b73e4c13fe8fa229a7

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