diff --git a/Dockerfile b/Dockerfile index 1a7532e..32a2918 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,8 @@ WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app - +COPY src /app/ + # Install dependencies RUN uv sync --frozen --no-install-project @@ -16,4 +17,4 @@ RUN uv sync --frozen --no-install-project RUN uv sync --frozen # Command to run the app when the container starts -CMD ["uv", "run", "src/main.py"] +CMD ["uv", "run", "test_main.py"] diff --git a/src/main.py b/src/main.py index 3cc976d..5a8e58f 100644 --- a/src/main.py +++ b/src/main.py @@ -1,10 +1,11 @@ from fastapi import FastAPI from fastapi.responses import RedirectResponse -from routers.health import health_router -from routers.mtcars import data_output +from src.routers.health import health_router +from src.routers.mtcars import data_output import uvicorn import tomllib +# Import pyproject toml info using tomllib try: with open("pyproject.toml", "rb") as f: tomldata = tomllib.load(f) diff --git a/test_main.py b/test_main.py new file mode 100644 index 0000000..e6aada7 --- /dev/null +++ b/test_main.py @@ -0,0 +1,37 @@ +from fastapi import FastAPI +from fastapi.responses import RedirectResponse +from routers.health import health_router +from routers.mtcars import data_output +from docs.documentation import description +import uvicorn + +app = FastAPI( + # This info goes directly into /docs + title="RMI Web API poc", + # Description of API defined in docs/documentation.py for ease of reading + description=description, + summary="This project is a proof-of-concept (POC) web API built using the FastAPI library.", + version="0.0.1", + contact={ + "name": "RMI", + "url": "https://github.com/RMI", + }, + license_info={ + "name": "MIT", + "url": "https://github.com/RMI/web-api-poc/blob/main/LICENSE.txt", + }, +) + + +@app.get("/") +async def redirect(): + response = RedirectResponse(url="/docs") + return response + + +app.include_router(health_router) +app.include_router(data_output) + + +if __name__ == "__main__": + uvicorn.run("main:app", host="0.0.0.0", port=5000, log_level="info")