mirror of
https://github.com/Redume/Shirino.git
synced 2025-04-02 18:57:34 +03:00
chore: simple backend
This commit is contained in:
parent
7a246c8b92
commit
ea723ec645
2 changed files with 42 additions and 0 deletions
33
web-app/app.py
Normal file
33
web-app/app.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi import FastAPI
|
||||
|
||||
import yaml
|
||||
import uvicorn
|
||||
|
||||
from routes import home
|
||||
|
||||
app = FastAPI()
|
||||
config = yaml.safe_load(open('./config.yaml'))
|
||||
|
||||
app.mount('/static/', StaticFiles(directory='./web/static/'))
|
||||
app.mount('/node_modules', StaticFiles(directory='./web/node_modules/'))
|
||||
|
||||
app.include_router(home.router)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run(
|
||||
app,
|
||||
host=config['server']['host'],
|
||||
port=5050,
|
||||
ssl_keyfile=
|
||||
config['server']['ssl_privkey']
|
||||
if config['server']['ssl_work']
|
||||
else None,
|
||||
ssl_certfile=
|
||||
config['server']['ssl_cert']
|
||||
if config['server']['ssl_work']
|
||||
else None
|
||||
)
|
9
web-app/routes/home.py
Normal file
9
web-app/routes/home.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from fastapi import APIRouter, Request
|
||||
from starlette.responses import FileResponse, HTMLResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get('/', response_class=HTMLResponse)
|
||||
async def home(req: Request):
|
||||
return FileResponse('./web/html/index.html')
|
Loading…
Add table
Add a link
Reference in a new issue