| 1 |
from datetime import datetime |
| 2 |
|
| 3 |
from fastapi import FastAPI |
| 4 |
from pydantic import BaseModel |
| 5 |
|
| 6 |
app = FastAPI() |
| 7 |
|
| 8 |
|
| 9 |
class Subscription(BaseModel): |
| 10 |
username: str |
| 11 |
monthly_fee: float |
| 12 |
start_date: datetime |
| 13 |
|
| 14 |
|
| 15 |
@app.webhooks.post("new-subscription") |
| 16 |
def new_subscription(body: Subscription): |
| 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 |
""" |
| 21 |
|
| 22 |
|
| 23 |
@app.get("/users/") |
| 24 |
def read_users(): |
| 25 |
return ["Rick", "Morty"] |