Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import uvicorn
- from fastapi import FastAPI
- from pydantic import BaseModel, create_model
- app = FastAPI()
- class StaticModel(BaseModel):
- attrib: int = 3
- class Endpoint:
- def __init__(self):
- self.request_model = create_model('DynamicModel', params=(int, 3))
- endpoint = Endpoint()
- @app.post("/")
- async def handler(request: endpoint.request_model):
- print(request)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement