|
@@ -19,6 +19,8 @@ from sqlalchemy.sql.elements import False_
|
|
|
# import datetime
|
|
|
from datetime import timedelta, datetime
|
|
|
# db
|
|
|
+import pymysql
|
|
|
+from pymysql import cursors
|
|
|
import dataset
|
|
|
from passlib import context
|
|
|
import models
|
|
@@ -31,7 +33,7 @@ from fastapi_jwt_auth import AuthJWT
|
|
|
from fastapi_jwt_auth.exceptions import AuthJWTException
|
|
|
from fastapi.security import OAuth2AuthorizationCodeBearer, OAuth2PasswordRequestForm
|
|
|
import numpy as np
|
|
|
-import pymysql
|
|
|
+import mysql.connector
|
|
|
pymysql.install_as_MySQLdb()
|
|
|
db_settings = {
|
|
|
"host": "db.ptt.cx",
|
|
@@ -155,13 +157,16 @@ async def tower(request: Request, Authorize: AuthJWT = Depends()):
|
|
|
|
|
|
@app.get('/optim', response_class=HTMLResponse)
|
|
|
async def optim(request: Request, Authorize: AuthJWT = Depends()):
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/Water_tower?charset=utf8mb4')
|
|
|
+ table=db['record_tower']
|
|
|
+ temp = table.find_one(key = 'hotTemp')
|
|
|
try:
|
|
|
Authorize.jwt_required()
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return RedirectResponse('/login')
|
|
|
# current_user = Authorize.get_jwt_subject()
|
|
|
- return templates.TemplateResponse(name='optim.html', context={'request': request})
|
|
|
+ return templates.TemplateResponse(name='optim.html',context={'request': request,"temp":temp})
|
|
|
|
|
|
|
|
|
@app.get('/vibration', response_class=HTMLResponse)
|