Giter Club home page Giter Club logo

gladius's Introduction

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

gladius's People

Contributors

mtasic85 avatar

Stargazers

Eder Sosa avatar Joel Mason avatar

Watchers

 avatar  avatar

gladius's Issues

whole body swap on any event

Currently, if one POST event is fired, for every listening component GET is fired which is very expensive.
Current workaround idea is that if one POST event fires, only body's GET fires.
Later on, we can use library as the swapping mechanism in htmx.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.