Quick Start
Build your first Flaxon application in minutes.
Create a Project
mkdir my-flaxon-app
cd my-flaxon-app
python -m venv .venv
source .venv/bin/activate
pip install flaxon[standard]
Create app.py
from flaxon import Flaxon
app = Flaxon("hello-world", debug=True)
@app.get("/")
async def home():
return {"message": "Hello, World!"}
@app.get("/health")
async def health():
return {"status": "healthy", "service": "hello-world"}
Run It
flaxon run app:app --reload
Visit http://localhost:8000 to see your API.
Add a Route with Parameters
@app.get("/users/<int:user_id>")
async def get_user(user_id: int):
return {"id": user_id, "name": f"User {user_id}"}
Visit http://localhost:8000/users/42
Add Validation
from flaxon.validation import Schema, fields
class CreateUser(Schema):
name = fields.String(required=True, min_length=2, max_length=80)
email = fields.Email(required=True)
age = fields.Integer(required=False, minimum=13, maximum=120)
@app.post("/users")
async def create_user(data: CreateUser):
return {"success": True, "user": data.to_dict()}
Add a WebSocket
@app.websocket("/ws/echo")
async def echo(socket):
await socket.accept()
async for message in socket.iter_json():
await socket.send_json({"echo": message})
Done!
You've built your first Flaxon application. Check the documentation for more.