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!"
|
24
backend/vntypes.py
Normal file
24
backend/vntypes.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
class Novel(BaseModel):
|
||||
title: str
|
||||
description: str
|
||||
|
||||
vndb: int | None = None
|
||||
hours_to_read: int
|
||||
|
||||
tags: list[str]
|
||||
genres: list[str]
|
||||
badges: list[str]
|
||||
|
||||
tg_post: str | None = None #url::Url
|
||||
post_at: datetime | None = None
|
||||
|
||||
class FullNovel:
|
||||
data: Novel
|
||||
|
||||
upload_queue: list[str]
|
||||
files: list[str]
|
||||
screenshots: list[str]
|
Loading…
Add table
Add a link
Reference in a new issue