Skip to content

Commit

Permalink
feat(init): first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
itayB committed Apr 3, 2024
0 parents commit de2c3ea
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__
venv
Empty file added backend/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions backend/__main__.py
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()
26 changes: 26 additions & 0 deletions backend/health_router.py
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"}
3 changes: 3 additions & 0 deletions requirements.txt
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

0 comments on commit de2c3ea

Please sign in to comment.