irt-service/app/main.py
2021-09-14 14:11:19 -04:00

40 lines
942 B
Python

from fastapi import FastAPI, __version__
from pydantic import BaseModel
from typing import Set, List, Optional, Dict
from random import randint
from models.solver_run import SolverRun
from models.solution import Solution
from models.form import Form
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Welcome to Measures LOFT solver service. v0.1"}
@app.get("/healthcheck")
async def health():
content = {
"maintainer": "Meazure Horizon Team",
"git_repo": "https://github.com/yardstick/measure-solver",
"server": "OK",
"fastapi version": __version__,
"app version": "0.1.1"
}
return content
@app.get('/readycheck')
async def ready():
return 'OK' # just means we're on air
@app.post('/solve/')
async def solve(solver_run: SolverRun):
response = Solution(
response_id=randint(100,5000),
forms=[Form(
items=[item.id for item in solver_run.items]
)]
)
return response