mirror of
https://github.com/xiaozhou233/RiverWaterQualityMonitoring.git
synced 2026-12-05 13:05:53 +08:00
更新配置文件,移除重复定义的DATA_FILE,优化数据上传路由中的时间处理
This commit is contained in:
1 parent
83b724598a
commit
4881794e2d
3 files changed
+9
-8
No files matched your search
@@ -1,3 +1,4 @@
|
||||
###
|
||||
TOKEN = "mE7yG0kI"
|
||||
DATA_FILE = "database.csv"
|
||||
###
|
||||
+2
-5
@@ -1,12 +1,9 @@
|
||||
import csv
|
||||
import os
|
||||
from collections import deque
|
||||
from config import *
|
||||
|
||||
###
|
||||
DATA_FILE = "database.csv"
|
||||
###
|
||||
|
||||
# time, ph, tds, turbidity
|
||||
# 表头: time, ph, tds, turbidity
|
||||
|
||||
# 插入数据
|
||||
def insert_data(time, ph, tds, turbidity):
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
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" : timenow()
|
||||
"time" : time
|
||||
}
|
||||
|
||||
# TODO: Insert data into database
|
||||
insert_data(time, ph, tds, turbidity)
|
||||
|
||||
return {
|
||||
"code" : 200,
|
||||
"status" : "success",
|
||||
"message" : "data upload success",
|
||||
"time" : timenow()
|
||||
"time" : time
|
||||
}
|
||||
Reference in new issue
Block a user