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
AppModelclass defines the application's state. In this example, it stores the user's name and the greeting message. -
Update: The
updatefunction 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
viewfunction renders the UI based on the current model state. It returns a tree ofElementobjects 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
FastTEA: A Python Developer's Quest for Elegant Web Apps - Part 2 https://medium.com/@hebi_73682/fasttea-a-python-developers-quest-for-elegant-web-apps-part-2-a25fc77e09c3
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! 🍵✨
Metadata
Release files for fasttea-web 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fasttea_web-0.3.0.tar.gz | 11.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fasttea_web-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.5 kB
Release files / fasttea_web-0.3.0.tar.gz
| Download URL | fasttea_web-0.3.0.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82e6c45fcd63c2b175bfefcb27634d0d2def8196e04473b3c753a4e6274e1840
|
|
BLAKE2b-256 checksum How to use checksums |
cfb77bba436d468cade58494dae7256bbd7dde4bea97eca6c9665430c46cfc3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / fasttea_web-0.3.0-py3-none-any.whl
| Download URL | fasttea_web-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b09a086603b326cd141c1e0057cabd56db53af2dd349b202d32c7d0936ca1bbe
|
|
BLAKE2b-256 checksum How to use checksums |
d04ccffc8beadd8f3c1945b8b4ca9523c6892db8206c0b82a1dc9b52c324e179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|