backend: initial
This commit is contained in:
parent
e5932844e2
commit
b62f6d87c7
33 changed files with 59 additions and 15 deletions
32
backend/main.py
Normal file
32
backend/main.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from vntypes import Novel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
origins = [
|
||||
"http://localhost",
|
||||
"http://localhost:5173",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
|
||||
@app.get("/posts/{uuid}")
|
||||
def get_post(uuid: str):
|
||||
return uuid
|
||||
|
||||
@app.post("/new")
|
||||
def new_post(novel: Novel):
|
||||
print(novel)
|
||||
return "yay!"
|
Loading…
Add table
Add a link
Reference in a new issue