Skip to content

Commit

Permalink
info router
Browse files Browse the repository at this point in the history
  • Loading branch information
vedina committed Aug 11, 2023
1 parent 58a0123 commit 4daed16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/api/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from fastapi import APIRouter
import subprocess

router = APIRouter()

@router.get("/info")
async def get_build_number():
try:
# Run the "git rev-parse HEAD" command to get the latest commit hash
commit_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
return {"build_number": commit_hash}
except Exception as e:
return {"error": str(e)}
3 changes: 2 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi import FastAPI
from app.api import upload, process # Import your endpoint modules
from app.api import upload, process, info # Import your endpoint modules

from pydantic import BaseSettings

Expand All @@ -10,6 +10,7 @@
# Include your API endpoint routers here
app.include_router(upload.router, prefix="", tags=["dataset"])
app.include_router(process.router, prefix="", tags=["process"])
app.include_router(info.router, prefix="", tags=["info"])

for route in app.routes:
print(f"Route: {route.path} | Methods: {route.methods}")
Expand Down

0 comments on commit 4daed16

Please sign in to comment.