Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #40

Merged
merged 8 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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

# Sync the 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"]
5 changes: 3 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
37 changes: 37 additions & 0 deletions test_main.py
Original file line number Diff line number Diff line change
@@ -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")