Skip to content

Commit 8959d18

Browse files
Refactor project into a dedicated 'server' module and update all references accordingly
1 parent 71b1167 commit 8959d18

25 files changed

+27
-27
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ USER appuser
4141

4242
EXPOSE 8000
4343

44-
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
44+
CMD ["python", "-m", "uvicorn", "server.main:app", "--host", "0.0.0.0", "--port", "8000"]

src/routers/__init__.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/server/__init__.py

Whitespace-only changes.

src/main.py renamed to src/server/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from starlette.middleware.trustedhost import TrustedHostMiddleware
1919

2020
from config import DELETE_REPO_AFTER, TMP_BASE_PATH
21-
from routers import download, dynamic, index
22-
from server_utils import limiter
21+
from server.routers import download, dynamic, index
22+
from server.server_utils import limiter
2323

2424
# Load environment variables from .env file
2525
load_dotenv()
@@ -156,7 +156,7 @@ async def rate_limit_exception_handler(request: Request, exc: Exception) -> Resp
156156
app.add_exception_handler(RateLimitExceeded, rate_limit_exception_handler)
157157

158158
# Mount static files to serve CSS, JS, and other static assets
159-
app.mount("/static", StaticFiles(directory="static"), name="static")
159+
app.mount("/server/static", StaticFiles(directory="server/static"), name="static")
160160

161161
# Set up API analytics middleware if an API key is provided
162162
if app_analytics_key := os.getenv("API_ANALYTICS_KEY"):
@@ -175,7 +175,7 @@ async def rate_limit_exception_handler(request: Request, exc: Exception) -> Resp
175175
app.add_middleware(TrustedHostMiddleware, allowed_hosts=allowed_hosts)
176176

177177
# Set up template rendering
178-
templates = Jinja2Templates(directory="templates")
178+
templates = Jinja2Templates(directory="server/templates")
179179

180180

181181
@app.get("/health")
@@ -235,7 +235,7 @@ async def robots() -> FileResponse:
235235
FileResponse
236236
The `robots.txt` file located in the static directory.
237237
"""
238-
return FileResponse("static/robots.txt")
238+
return FileResponse("server/static/robots.txt")
239239

240240

241241
# Include routers for modular endpoints
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from gitingest.query_ingestion import run_ingest_query
1111
from gitingest.query_parser import ParsedQuery, parse_query
1212
from gitingest.repository_clone import CloneConfig, clone_repo
13-
from server_utils import Colors, log_slider_to_size
13+
from server.server_utils import Colors, log_slider_to_size
1414

15-
templates = Jinja2Templates(directory="templates")
15+
templates = Jinja2Templates(directory="server/templates")
1616

1717

1818
async def process_query(

src/server/routers/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
""" This module contains the routers for the FastAPI application. """
2+
3+
from server.routers.download import router as download
4+
from server.routers.dynamic import router as dynamic
5+
from server.routers.index import router as index
6+
7+
__all__ = ["download", "dynamic", "index"]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from fastapi.responses import HTMLResponse
55
from fastapi.templating import Jinja2Templates
66

7-
from query_processor import process_query
8-
from server_utils import limiter
7+
from server.query_processor import process_query
8+
from server.server_utils import limiter
99

1010
router = APIRouter()
11-
templates = Jinja2Templates(directory="templates")
11+
templates = Jinja2Templates(directory="server/templates")
1212

1313

1414
@router.get("/{full_path:path}")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from fastapi.templating import Jinja2Templates
66

77
from config import EXAMPLE_REPOS
8-
from query_processor import process_query
9-
from server_utils import limiter
8+
from server.query_processor import process_query
9+
from server.server_utils import limiter
1010

1111
router = APIRouter()
12-
templates = Jinja2Templates(directory="templates")
12+
templates = Jinja2Templates(directory="server/templates")
1313

1414

1515
@router.get("/", response_class=HTMLResponse)

0 commit comments

Comments
 (0)