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"
|
TOKEN = "mE7yG0kI"
|
||||||
|
DATA_FILE = "database.csv"
|
||||||
###
|
###
|
||||||
+2
-5
@@ -1,12 +1,9 @@
|
|||||||
import csv
|
import csv
|
||||||
import os
|
import os
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
from config import *
|
||||||
|
|
||||||
###
|
# 表头: time, ph, tds, turbidity
|
||||||
DATA_FILE = "database.csv"
|
|
||||||
###
|
|
||||||
|
|
||||||
# time, ph, tds, turbidity
|
|
||||||
|
|
||||||
# 插入数据
|
# 插入数据
|
||||||
def insert_data(time, ph, tds, turbidity):
|
def insert_data(time, ph, tds, turbidity):
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
import config
|
import config
|
||||||
from utils import *
|
from utils import *
|
||||||
|
from data import *
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.get("/data/upload")
|
@router.get("/data/upload")
|
||||||
def data_upload_get(token:str, ph:float, tds:float, turbidity:float):
|
def data_upload_get(token:str, ph:float, tds:float, turbidity:float):
|
||||||
|
time = timenow()
|
||||||
|
|
||||||
# 验证token
|
# 验证token
|
||||||
if token != config.TOKEN:
|
if token != config.TOKEN:
|
||||||
return {
|
return {
|
||||||
"code" : 403,
|
"code" : 403,
|
||||||
"status" : "error",
|
"status" : "error",
|
||||||
"message" : "token error",
|
"message" : "token error",
|
||||||
"time" : timenow()
|
"time" : time
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Insert data into database
|
insert_data(time, ph, tds, turbidity)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"code" : 200,
|
"code" : 200,
|
||||||
"status" : "success",
|
"status" : "success",
|
||||||
"message" : "data upload success",
|
"message" : "data upload success",
|
||||||
"time" : timenow()
|
"time" : time
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user