-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (25 loc) · 805 Bytes
/
main.py
File metadata and controls
31 lines (25 loc) · 805 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 Union
from fastapi import FastAPI, HTTPException, APIRouter
import logging
import os
# FastAPI 애플리케이션 생성
app = FastAPI()
router = APIRouter()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/uwb/{tag_id}")
def read_item(tag_id: int):
try:
temp_filename = "../shared/temp" + str(tag_id)
with open(temp_filename + ".txt", 'r') as f:
line = f.readline()
return line
except Exception as e:
logging.error(f"An unexpected error occurred: {e}")
raise HTTPException(status_code=404, detail="Not Vaild tag ID")
app.include_router(router, prefix="/api")
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
# uwb의 좌표를 보내는 api server