Coverage for docs_src/openapi_webhooks/tutorial001.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from datetime import datetime 1abcde
3from fastapi import FastAPI 1abcde
4from pydantic import BaseModel 1abcde
6app = FastAPI() 1abcde
9class Subscription(BaseModel): 1abcde
10 username: str 1abcde
11 monthly_fee: float 1abcde
12 start_date: datetime 1abcde
15@app.webhooks.post("new-subscription") 1abcde
16def new_subscription(body: Subscription): 1abcde
17 """
18 When a new user subscribes to your service we'll send you a POST request with this
19 data to the URL that you register for the event `new-subscription` in the dashboard.
20 """
23@app.get("/users/") 1abcde
24def read_users(): 1abcde
25 return ["Rick", "Morty"] 1abcde