-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (23 loc) · 686 Bytes
/
app.py
File metadata and controls
32 lines (23 loc) · 686 Bytes
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
from typing import List
from fastapi import FastAPI
from pydantic import BaseModel
from src.welcome import greet
from src.ageLimit import validateAge
app = FastAPI()
class RequestJson1(BaseModel):
name:str
class RequestJson2(BaseModel):
age:int
@app.post("/welcome")
def welcome(requestJson:RequestJson1):
welcomeString = greet(requestJson.name)
response = {"output":welcomeString}
return response
@app.post("/validateAge")
def ageLimit(requestJson:RequestJson2):
age = validateAge(requestJson.age)
if age == True:
response = {"output":"You are eligible."}
else:
response = {"output":"You are not eligible."}
return response