There was an error while loading. Please reload this page.
from fastapi import FastAPI app = FastAPI() @app.get("/") def root(): return "Hello, world!"
import happyx serve "127.0.0.1", 5000: get "/": return "Hello, world!"
@app.get("/user/{id}") def get_user_by_id(id: int): return {"response": id}
get "/user/{id:int}": return {"response": id}
In FastAPI you can use pydantic to create models
from pydantic import BaseModel from fastapi import FastAPI class User(BaseModel): username: str age: int app = FastAPI() @app.post("/") def create_user(user: User): # create user return {"response": { "id": 0, "username": user.username }}
In HappyX you can use built-in request models that supports JSON, XML, form-data and x-www-form-urlencoded body
import happyx model User: username: string age: int serve "127.0.0.1", 5000: post "/[user:User]": # create user return {"response": { "id": 0, "username": user.username }}