Skip to content

Instantly share code, notes, and snippets.


cosmic-cortex/ Secret

Last active May 29, 2020
What would you like to do?
from fastapi import FastAPI, Depends
from pydantic import BaseModel
class Comment(BaseModel):
username: str
content: str
app = FastAPI()
database = {
"articles": {
1: {
"title": "Top 3 Reasons to Start Using FastAPI Now",
"comments": []
def get_database():
return database"/articles/{article_id}/comments")
def post_comment(article_id: int, comment: Comment, database = Depends(get_database)):
return {"msg": "comment posted!"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment