added token to request object, as well as created response object
This commit is contained in:
parent
c4fdd68af2
commit
8ac5d5efdb
10
app/main.py
10
app/main.py
@ -1,8 +1,11 @@
|
|||||||
from fastapi import FastAPI, __version__
|
from fastapi import FastAPI, __version__
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import Set, List, Optional, Dict
|
from typing import Set, List, Optional, Dict
|
||||||
|
from random import randint
|
||||||
|
|
||||||
from models.solver_content import SolverContent
|
from models.solve_request import SolveRequest
|
||||||
|
from models.solve_response import SolveResponse
|
||||||
|
from models.form import Form
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@ -26,5 +29,6 @@ async def ready():
|
|||||||
return 'OK' # just means we're on air
|
return 'OK' # just means we're on air
|
||||||
|
|
||||||
@app.post('/solve/')
|
@app.post('/solve/')
|
||||||
async def solve(solver_content: SolverContent):
|
async def solve(solve_request: SolveRequest):
|
||||||
return solver_content
|
response = SolveResponse(response_id=randint(100,5000), forms=[Form(items=solve_request.items)])
|
||||||
|
return response
|
||||||
|
7
app/models/form.py
Normal file
7
app/models/form.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from models.item import Item
|
||||||
|
|
||||||
|
class Form(BaseModel):
|
||||||
|
items: List[Item]
|
@ -7,7 +7,8 @@ from models.irt_model import IRTModel
|
|||||||
from models.objective_function import ObjectiveFunction
|
from models.objective_function import ObjectiveFunction
|
||||||
from models.advanced_options import AdvancedOptions
|
from models.advanced_options import AdvancedOptions
|
||||||
|
|
||||||
class SolverContent(BaseModel):
|
class SolveRequest(BaseModel):
|
||||||
|
token: str
|
||||||
items: List[Item]
|
items: List[Item]
|
||||||
constraints: List[Constraint]
|
constraints: List[Constraint]
|
||||||
irt_model: IRTModel
|
irt_model: IRTModel
|
8
app/models/solve_response.py
Normal file
8
app/models/solve_response.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
from models.form import Form
|
||||||
|
|
||||||
|
class SolveResponse(BaseModel):
|
||||||
|
response_id: int
|
||||||
|
forms: List[Form]
|
@ -1,8 +1,8 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
class Targets(BaseModel):
|
class Targets(BaseModel):
|
||||||
neg_2_5: int
|
n_2_5: int
|
||||||
neg_1_5: int
|
n_1_5: int
|
||||||
neg_0_5: int
|
n_0_5: int
|
||||||
_0_5: int
|
p_0_5: int
|
||||||
_1: int
|
p_1: int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user