|
@@ -0,0 +1,100 @@
|
|
|
|
+import os
|
|
|
|
+import time
|
|
|
|
+import paramiko
|
|
|
|
+from flask import Flask, render_template, request, url_for, redirect
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import paramiko
|
|
|
|
+import pymysql
|
|
|
|
+
|
|
|
|
+import logging
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+from logging.handlers import RotatingFileHandler
|
|
|
|
+
|
|
|
|
+def make_dir(make_dir_path):
|
|
|
|
+ path = make_dir_path.strip()
|
|
|
|
+ if not os.path.exists(path):
|
|
|
|
+ os.makedirs(path)
|
|
|
|
+
|
|
|
|
+def getLogHandler():
|
|
|
|
+
|
|
|
|
+ log_dir_name = "/.log"
|
|
|
|
+
|
|
|
|
+ log_file_name = 'logger-' + time.strftime('%Y-%m-%d', time.localtime(time.time())) + '.log'
|
|
|
|
+
|
|
|
|
+ log_file_folder = os.path.abspath(
|
|
|
|
+ os.path.join(os.path.dirname(__file__), os.pardir)) + os.sep + log_dir_name
|
|
|
|
+ make_dir(log_file_folder)
|
|
|
|
+ log_file_str = log_file_folder + os.sep + log_file_name
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ logging.basicConfig(level=logging.INFO)
|
|
|
|
+
|
|
|
|
+ file_log_handler = RotatingFileHandler(log_file_str, maxBytes=1024 * 1024, backupCount=10, encoding='UTF-8')
|
|
|
|
+
|
|
|
|
+ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)s - %(message)s')
|
|
|
|
+
|
|
|
|
+ file_log_handler.setFormatter(formatter)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return file_log_handler
|
|
|
|
+
|
|
|
|
+app = Flask(__name__)
|
|
|
|
+
|
|
|
|
+app.logger.addHandler(getLogHandler())
|
|
|
|
+
|
|
|
|
+ctx = app.app_context()
|
|
|
|
+ctx.push()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+conn = pymysql.connect(
|
|
|
|
+ host='52.69.200.169',
|
|
|
|
+ user='coffee',
|
|
|
|
+ password='skyeye',
|
|
|
|
+ db='Coffee',
|
|
|
|
+ charset='utf8'
|
|
|
|
+)
|
|
|
|
+port = '22'
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@app.route("/")
|
|
|
|
+def index():
|
|
|
|
+ return render_template("index.html", title='ERP WEB')
|
|
|
|
+
|
|
|
|
+@app.route("/check_Peel_Output_status",methods=['POST', 'GET'])
|
|
|
|
+def check_Peel_Output_status():
|
|
|
|
+ if request.method == 'POST':
|
|
|
|
+ cur = conn.cursor()
|
|
|
|
+
|
|
|
|
+ sql = "SELECT `Peel_Output_1`,`Peel_Output_2` FROM `clean_container_status` ORDER BY `sn` DESC LIMIT 1"
|
|
|
|
+
|
|
|
|
+ cur.execute(sql)
|
|
|
|
+ get_Peel_Output_status = cur.fetchone()
|
|
|
|
+
|
|
|
|
+ cur1 = conn.cursor()
|
|
|
|
+ sql1 = "SELECT `Ferment_Input_1`,`Ferment_Input_2` FROM `ferment_container_status` ORDER BY `sn` DESC LIMIT 1 "
|
|
|
|
+ cur1.execute(sql1)
|
|
|
|
+ get_Ferment_Input = cur1.fetchone()
|
|
|
|
+
|
|
|
|
+ return render_template('test.html',**locals())
|
|
|
|
+ return render_template("index.html")
|
|
|
|
+
|
|
|
|
+@app.before_request
|
|
|
|
+def log_each_request():
|
|
|
|
+ app.logger.info('【請求方法】{}【請求路徑】{}【請求IP】{}'.format(request.method, request.path, request.remote_addr))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ app.run(debug=True,host = '0.0.0.0' , port=5566)
|
|
|
|
+
|