-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (34 loc) · 832 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from typing import Union
from fastapi import FastAPI
app = FastAPI()
f = open("count.txt", 'r')
line = f.read()
count = int(line)
f.close()
# f = open("count.txt", 'w')
# f.write("hi")
# f.close
@app.get("/plus")
def counter():
global count
count = count + 1
f = open("count.txt", 'w')
f.write(str(count))
f.close
return "1 증가"
@app.get("/lookup")
def look():
global count
return count
@app.get("/mul/{item1}/{item2}")
def mul(item1:int, item2:int):
return {item1*item2}
@app.get("/add/{item1}/{item2}")
def add(item1: int, item2: int):
return {"result": item1 + item2}
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}