-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de2c3ea
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__pycache__ | ||
venv |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from distutils.sysconfig import get_python_lib | ||
from fastapi import FastAPI | ||
from fastapi.responses import FileResponse | ||
from fastapi.staticfiles import StaticFiles | ||
from backend.health_router import router | ||
from uvicorn import run | ||
|
||
|
||
def create_app(): | ||
app = FastAPI( | ||
title="Backend Server", | ||
) | ||
app.include_router(router) | ||
|
||
client_path = f"{get_python_lib()}/vite_project" | ||
app.mount("/assets", StaticFiles(directory=f"{client_path}/assets"), name="assets") | ||
app.mount("/static", StaticFiles(directory=f"{client_path}/static"), name="static") | ||
|
||
@app.get("/{catchall:path}") | ||
async def serve_react_app(catchall: str): | ||
return FileResponse(f"{client_path}/index.html") | ||
|
||
return app | ||
|
||
|
||
def main(): | ||
app = create_app() | ||
run(app, host="0.0.0.0", port=8080) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Literal | ||
from typing_extensions import TypedDict | ||
from fastapi import APIRouter, status | ||
|
||
STATUS = Literal["success", "error", "partial", "unknown"] | ||
|
||
|
||
class ReturnHealthcheckStruct(TypedDict): | ||
status: STATUS | ||
|
||
|
||
router = APIRouter( | ||
prefix="/v1/health-check", | ||
tags=["Health Check"], | ||
) | ||
|
||
|
||
@router.get( | ||
"/liveness", | ||
summary="Perform a Liveness Health Check", | ||
response_description="Return HTTP Status Code 200 (OK)", | ||
status_code=status.HTTP_200_OK, | ||
response_model=ReturnHealthcheckStruct, | ||
) | ||
async def liveness() -> ReturnHealthcheckStruct: | ||
return {"status": "success"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fastapi==0.110.0 | ||
uvicorn==0.29.0 | ||
vite-project==1.0.5 |