From 43869ac372515f4710e2e127b14a2816d46f1865 Mon Sep 17 00:00:00 2001 From: EremeevRA Date: Fri, 20 Mar 2026 17:28:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=BC=D0=B5=D1=80=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ .vscode/launch.json | 20 ++++++++++++++++++++ api/__init__.py | 2 ++ api/main.py | 24 ++++++++++++++++++++++++ api/routers/__init__.py | 2 ++ api/routers/health.py | 14 ++++++++++++++ requirements.txt | 2 ++ 7 files changed, 66 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 api/__init__.py create mode 100644 api/main.py create mode 100644 api/routers/__init__.py create mode 100644 api/routers/health.py create mode 100644 requirements.txt 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]