mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-16 23:24:39 -04:00
📝 Update source examples and docs from Python 3.9 to 3.10 (#14900)
This commit is contained in:
1 parent
d06ab3f5c7
commit
c9e2277d8b
655 files changed
+3703
-5660
No files matched your search
@@ -0,0 +1,25 @@
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Subscription(BaseModel):
|
||||
username: str
|
||||
monthly_fee: float
|
||||
start_date: datetime
|
||||
|
||||
|
||||
@app.webhooks.post("new-subscription")
|
||||
def new_subscription(body: Subscription):
|
||||
"""
|
||||
When a new user subscribes to your service we'll send you a POST request with this
|
||||
data to the URL that you register for the event `new-subscription` in the dashboard.
|
||||
"""
|
||||
|
||||
|
||||
@app.get("/users/")
|
||||
def read_users():
|
||||
return ["Rick", "Morty"]
|
||||
Reference in new issue
Block a user