-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
46 lines (38 loc) · 1.26 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
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)
version = tomldata["project"]["version"]
description = tomldata["project"]["description"]
except FileNotFoundError:
print("pyproject.toml not found")
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")