Skip to content

Commit 49fb42a

Browse files
authored
feat: version and description pulled from toml (#33)
* version and description pulled from toml * black reformatting
1 parent 0a3de78 commit 49fb42a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
from fastapi.responses import RedirectResponse
33
from routers.health import health_router
44
from routers.mtcars import data_output
5-
from docs.documentation import description
65
import uvicorn
6+
import tomllib
7+
8+
try:
9+
with open("pyproject.toml", "rb") as f:
10+
tomldata = tomllib.load(f)
11+
version = tomldata["project"]["version"]
12+
description = tomldata["project"]["description"]
13+
except FileNotFoundError:
14+
print("pyproject.toml not found")
715

816
app = FastAPI(
917
# This info goes directly into /docs
1018
title="RMI Web API poc",
1119
# Description of API defined in docs/documentation.py for ease of reading
1220
description=description,
1321
summary="This project is a proof-of-concept (POC) web API built using the FastAPI library.",
14-
version="0.0.1",
22+
version=version,
1523
contact={
1624
"name": "RMI",
1725
"url": "https://github.com/RMI",

0 commit comments

Comments
 (0)