-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (36 loc) · 880 Bytes
/
main.py
File metadata and controls
38 lines (36 loc) · 880 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
32
33
34
35
36
37
38
from fastapi import FastAPI
from getcode import getcode
from Crypto.PublicKey import RSA
import asyncio
from pydantic import BaseModel
from fastapi.middleware.cors import CORSMiddleware
import time
app = FastAPI()
origins = [
"http://localhost.tiangolo.com",
"https://localhost.tiangolo.com",
"http://localhost",
"http://localhost:8080",
"https://auth.dgist.ac.kr",
'http://auth.dgist.ac.kr'
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
class codeParam(BaseModel):
id: str
pw: str
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.post("/code")
async def root(param:codeParam):
start=time.time()
a=getcode(param.id,param.pw)
code=await a;
print(f"time: {time.time()-start}")
return {"code": code}