fix: add 404 support
This commit is contained in:
parent
1ea9bde1b6
commit
cac2bbcc6f
@ -13,6 +13,13 @@ from fastapi import FastAPI, Form
|
|||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.middleware.gzip import GZipMiddleware
|
from fastapi.middleware.gzip import GZipMiddleware
|
||||||
|
|
||||||
|
from fastapi.responses import PlainTextResponse
|
||||||
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||||
|
from fastapi.exception_handlers import (
|
||||||
|
http_exception_handler,
|
||||||
|
request_validation_exception_handler,
|
||||||
|
)
|
||||||
|
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from starlette.responses import FileResponse, HTMLResponse
|
from starlette.responses import FileResponse, HTMLResponse
|
||||||
@ -52,6 +59,13 @@ def read_root():
|
|||||||
index_path = os.path.join('templates', 'index.html')
|
index_path = os.path.join('templates', 'index.html')
|
||||||
return FileResponse(index_path)
|
return FileResponse(index_path)
|
||||||
|
|
||||||
|
|
||||||
|
@app.exception_handler(StarletteHTTPException)
|
||||||
|
async def custom_http_exception_handler(request, exc):
|
||||||
|
print(f"OMG! An HTTP error!: {repr(exc)}")
|
||||||
|
index_path = os.path.join('templates', '404.html')
|
||||||
|
return FileResponse(index_path)
|
||||||
|
|
||||||
@app.post("/sim/current_gear")
|
@app.post("/sim/current_gear")
|
||||||
def simulate_current_gear(simcprofile: Annotated[str, Form()]):
|
def simulate_current_gear(simcprofile: Annotated[str, Form()]):
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
.gearcontainer {
|
.gearcontainer {
|
||||||
|
display: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user