-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.py
39 lines (32 loc) · 1.19 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import *
from api.temperature import temperature_app
from api.location import location_app
from api.single_datatype import single_datatype_app
from api.basic_datatype import basic_datatype_app
from datetime import datetime
import logging
app = Flask(__name__)
app.json.ensure_ascii = False
app.config["TEMPLATES_AUTO_RELOAD"] = True
# blueprints
app.register_blueprint(temperature_app)
app.register_blueprint(location_app)
app.register_blueprint(single_datatype_app)
app.register_blueprint(basic_datatype_app)
#log
today = datetime.now().strftime("%Y-%m-%d")
logging.basicConfig(filename='./log/record-'+ today + '.log', level=logging.DEBUG, encoding='utf-8', format=f'%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s')
## for console setting
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
## 設定輸出格式
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
## handler 設定輸出格式
console.setFormatter(formatter)
## 加入 hander 到 root logger
logging.getLogger('').addHandler(console)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=3500, debug=True)