diff --git a/.gitignore b/.gitignore index 36b13f1..d371000 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,5 @@ cython_debug/ # PyPI configuration file .pypirc +# Other +.DS_Store diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2ad1af3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "Python Debugger: FastAPI", + "type": "debugpy", + "request": "launch", + "module": "uvicorn", + "args": [ + "api.main:app", + "--reload" + ], + "jinja": true + } + ] +} \ No newline at end of file diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 0000000..5c8df80 --- /dev/null +++ b/api/__init__.py @@ -0,0 +1,2 @@ +"""FastAPI application package.""" + diff --git a/api/main.py b/api/main.py new file mode 100644 index 0000000..3ccbec4 --- /dev/null +++ b/api/main.py @@ -0,0 +1,24 @@ +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware + +from api.routers.health import router as health_router + + +app = FastAPI(title="Common FastAPI App") +app.include_router(health_router) + +# Keep permissive defaults; tighten for production deployments. +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + + +if __name__ == "__main__": + import uvicorn + + uvicorn.run("api.main:app", host="0.0.0.0", port=8000, reload=True) + diff --git a/api/routers/__init__.py b/api/routers/__init__.py new file mode 100644 index 0000000..aef9ce5 --- /dev/null +++ b/api/routers/__init__.py @@ -0,0 +1,2 @@ +"""Application routers package.""" + diff --git a/api/routers/health.py b/api/routers/health.py new file mode 100644 index 0000000..c7164fa --- /dev/null +++ b/api/routers/health.py @@ -0,0 +1,14 @@ +from fastapi import APIRouter + +router = APIRouter() + + +@router.get("/health") +def health() -> dict: + return {"status": "ok"} + + +@router.get("/") +def root() -> dict: + return {"message": "FastAPI is running"} + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..364e2ee --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +fastapi +uvicorn[standard]