- Notifications
You must be signed in to change notification settings - Fork 16.9k
/
Copy pathmain.py
40 lines (29 loc) · 757 Bytes
/
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
fromfastapiimportFastAPI
fromenumimportEnum
app=FastAPI()
@app.get("/hello")
asyncdefhello():
return"Welcome"
@app.get("/hello/{name}")
asyncdefhello(name):
returnf"Welcome {name}"
classAvailableCuisines(str, Enum):
indian="indian"
american="american"
italian="italian"
food_items= {
'indian' : [ "Samosa", "Dosa" ],
'american' : [ "Hot Dog", "Apple Pie"],
'italian' : [ "Ravioli", "Pizza"]
}
@app.get("/get_items/{cuisine}")
asyncdefget_items(cuisine: AvailableCuisines):
returnfood_items.get(cuisine)
coupon_code= {
1: '10%',
2: '20%',
3: '30%'
}
@app.get("/get_coupon/{code}")
asyncdefget_items(code: int):
return { 'discount_amount': coupon_code.get(code) }