feat: Add initial client and server templates for FastAPI tutorial.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from fastapi import FastAPI, Query
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# 메시지 저장을 위한 리스트
|
||||
messages = []
|
||||
|
||||
class Message(BaseModel):
|
||||
name: str
|
||||
message: str
|
||||
|
||||
@app.post("/messages")
|
||||
def post_message(msg: Message):
|
||||
|
||||
|
||||
@app.get("/messages")
|
||||
def get_messages(start: int = 0):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
# 터미널에서 직접 실행할 때를 위해 uvicorn 설정 추가
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
Reference in New Issue
Block a user