Advertisement
Guest User

Untitled

a guest
Feb 11th, 2024
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. import uvicorn
  2. from fastapi import FastAPI
  3. from pydantic import BaseModel, create_model
  4.  
  5. app = FastAPI()
  6.  
  7.  
  8. class StaticModel(BaseModel):
  9.     attrib: int = 3
  10.  
  11.  
  12. class Endpoint:
  13.     def __init__(self):
  14.         self.request_model = create_model('DynamicModel', params=(int, 3))
  15.  
  16.  
  17. endpoint = Endpoint()
  18.  
  19.  
  20. @app.post("/")
  21. async def handler(request: endpoint.request_model):
  22.     print(request)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement