fastTEA - Python-Web-Framework with fastAPI and htmx
Project description
fastTEA: Build Elegant Web Applications in Python
fastTEA is a powerful and intuitive Python framework for building web applications with ease. Inspired by The Elm Architecture (TEA), fastTEA brings simplicity and predictability to your Python web development workflow.
Features
- Simple and Intuitive: Build web apps using a clear, archtectural approach.
- Based on The Elm Architecture: Benefit from a time-tested, scalable architecture.
- FastAPI Backend: Leverage the speed and simplicity of FastAPI.
- HTMX Integration: Create dynamic UIs without writing JavaScript.
- Flexible CSS Framework Support: Choose from Pico, Bootstrap, or Tailwind CSS.
- Type Safety: Utilizes Pydantic for robust data validation.
Installation
Install fastTEA using pip:
pip install fasttea-web
Quick Start
Let's dive into a simple "Hello, World!" application to showcase the power and simplicity of fastTEA.
from fasttea import FastTEA, Model, Msg, Cmd, Element, CSSFramework
from fasttea.html import div, h1, input_, button, p
class AppModel(Model):
name: str = ""
greeting: str = ""
app = FastTEA(AppModel(), css_framework=CSSFramework.PICO)
@app.update
def update(msg: Msg, model: AppModel) -> tuple[AppModel, Cmd | None]:
if msg.action == "greet":
model.name = msg.value
model.greeting = f"Hello {msg.value}!"
return model, None
@app.view
def view(model: AppModel) -> Element:
return div({},
h1({}, "FastTEA Hello Example"),
input_({
"id": "input",
"type": "text",
"value": model.name,
"name": "name",
"placeholder": "Enter your name"
}, ""),
button({
"onClick": "greet",
"getValue": "input"
},"Greet"),
p ({}, model.greeting)
)
if __name__ == "__main__":
app.run()
Core Principles Explained
-
Model: The
AppModel
class defines the application's state. In this example, it stores the user's name and the greeting message. -
Update: The
update
function handles state changes based on messages. It takes the current model and a message, then returns the updated model and any commands to be executed. -
View: The
view
function renders the UI based on the current model state. It returns a tree ofElement
objects that fastTEA converts to HTML. -
HTMX Integration: fastTEA leverages HTMX for dynamic updates without writing JavaScript. The button in our example uses HTMX attributes to trigger a server request.
-
CSS Framework: fastTEA supports various CSS frameworks. In this example, we're using Pico CSS for a clean, minimal design.
Get Started Today!
fastTEA combines the best of Python, The Elm Architecture, and modern web technologies to provide a delightful development experience. Whether you're building a small prototype or a large-scale web application, fastTEA has you covered.
Start building your next web application with fastTEA and experience the joy of functional web development in Python!
More
FastTEA: A Python Developer's Quest for Elegant Web Apps - Part 1 https://medium.com/@hebi_73682/fasttea-a-python-developers-quest-for-elegant-web-apps-part-1-ef86461cbfc5
Coming Soon!
We're constantly working to improve fastTEA and add new features. Here's a sneak peek at what's coming:
-
More Examples: We're developing a variety of examples to showcase fastTEA's capabilities in different scenarios.
-
Simple Chatbot: A demonstration of how to implement a basic chatbot using fastTEA, showing off its real-time update capabilities.
-
Form Processing: Enhanced support for handling and processing form submissions, making it even easier to create data-entry applications.
-
Client-Side Commands: Introducing a way to define commands that can be executed locally in the browser, improving responsiveness and reducing server load for certain operations.
-
Server-Triggered Commands: Allowing the server to trigger these client-side commands, enabling more complex interactions between the server and client.
-
UiBubbles and CmdBubbles: More structure.
These upcoming features will make fastTEA even more powerful and flexible, opening up new possibilities for your web applications. Stay tuned for updates!
Happy coding with fastTEA! 🍵✨
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fasttea_web-0.2.0.tar.gz
.
File metadata
- Download URL: fasttea_web-0.2.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ad2e65db64fb3ced3e6ab314106c5c6f1df975c944792544513fc341b16ae7 |
|
MD5 | f03a4b465470204e7b74ed31738b5737 |
|
BLAKE2b-256 | 9c65bb4439147abf28631b37c57b3b92be17bb51be1818b7051b7cc1288cf7b6 |
File details
Details for the file fasttea_web-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: fasttea_web-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbf75ece9a1bff4021e7f68185d009834d92e949fde2d2b86e1eb1b4f14aa6fc |
|
MD5 | 08cc50f4d729ac47c58f340eaabb96af |
|
BLAKE2b-256 | a6cf0113a63e00ce2d876f65bbf2a9341bd97c616f8b6ac90a493a571b924acd |