mirror of
https://github.com/xiaozhou233/RiverWaterQualityMonitoring.git
synced 2026-12-05 21:15:55 +08:00
28 lines
607 B
Python
28 lines
607 B
Python
from fastapi import APIRouter
|
|
import config
|
|
from utils import *
|
|
from data import *
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/data/upload")
|
|
def data_upload_get(token:str, ph:float, tds:float, turbidity:float):
|
|
time = timenow()
|
|
|
|
# 验证token
|
|
if token != config.TOKEN:
|
|
return {
|
|
"code" : 403,
|
|
"status" : "error",
|
|
"message" : "token error",
|
|
"time" : time
|
|
}
|
|
|
|
insert_data(time, ph, tds, turbidity)
|
|
|
|
return {
|
|
"code" : 200,
|
|
"status" : "success",
|
|
"message" : "data upload success",
|
|
"time" : time
|
|
} |