Starlio-web/main.py

35 lines
825 B
Python
Raw Permalink Normal View History

from fastapi.staticfiles import StaticFiles
from starlette.responses import FileResponse
2024-09-18 21:31:09 +03:00
from fastapi import FastAPI
import uvicorn
import os
from src.routes import index
from src.routes import wallpaper
app = FastAPI()
app.include_router(index.router)
app.include_router(wallpaper.router)
app.mount('/static/', StaticFiles(directory='./src/web/static/'))
app.mount('/.well-known/', StaticFiles(directory='./.well-known/'))
@app.get('/app-ads.txt')
2024-09-25 15:36:55 +03:00
async def app_ads(req):
return FileResponse('./app-ads.txt')
2024-09-18 17:14:04 +03:00
@app.get('/robots.txt')
2024-09-25 15:36:55 +03:00
async def robots_txt(req):
return FileResponse('./robots.txt')
@app.exception_handler(404)
async def not_found(req, __):
2024-09-18 21:31:09 +03:00
return FileResponse('./src/web/html/error/404.html')
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=int(os.environ['PORT']))