-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (21 loc) · 878 Bytes
/
main.py
File metadata and controls
34 lines (21 loc) · 878 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
import uvicorn
from fastapi import FastAPI, Request
from fastapi import HTTPException, Header
from starlette.responses import JSONResponse
from api.exchange.upbit_exchange import Upbit
from api.exchange.binance_future_excahnge import Binance
from api.model import ExecuteRequest, ExecuteResponse
app = FastAPI(openapi_url=None, redoc_url=None)
@app.get("/")
def root():
return "OK"
@app.post("/execute", response_model=ExecuteRequest)
def execute_order(data: ExecuteRequest, response_model=ExecuteResponse):
try:
upbit = Upbit(account_name=data.account_name)
binance = Binance(account_name=data.account_name)
except Exception as e:
return JSONResponse(status_code=500, content=dict(msg=str(e)))
if __name__ == '__main__':
# uvicorn main:app --reload --host 0.0.0.0 --port 8000
uvicorn.run(app, host="0.0.0.0", port=8002)