添加前后端
This commit is contained in:
20
backend/main.py
Normal file
20
backend/main.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fastapi import FastAPI
|
||||
import uvicorn
|
||||
import random
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
|
||||
|
||||
@app.get("/hello/{name}")
|
||||
async def say_hello(name: str):
|
||||
return {"message": f"Hello {name}"}
|
||||
|
||||
@app.get("/api/random")
|
||||
async def random_number():
|
||||
return {"number": random.randint(1, 100)}
|
||||
|
||||
Reference in New Issue
Block a user