This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
69 lines (52 loc) · 2.06 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from flask import Flask
from flask_assets import Environment, Bundle
import logging
from logging.handlers import RotatingFileHandler
from platus.web import web
from platus.api import api
from platus.config import config
application = Flask(__name__,\
static_folder="platus/static/",\
template_folder="platus/templates/",
static_url_path="/static")
application.register_blueprint(web)
application.register_blueprint(api)
application.config.update(config.from_yaml("data/config.yaml"))
# Scss
assets = Environment(application)
assets.versions = 'timestamp'
assets.url_expire = True
assets.manifest = 'file:/tmp/manifest.to-be-deployed' # explict filename
assets.cache = False
assets.auto_build = True
assets.url = application.static_url_path
scss = Bundle('scss/00_main.scss', filters='pyscss', output='css/main.css', depends=['scss/*.scss'])
assets.register('scss_all', scss)
assets.debug = False
application.config['ASSETS_DEBUG'] = False
# Set Logger
log_levels = {
"info": logging.INFO,
"debug": logging.DEBUG,
"error": logging.ERROR,
"critical": logging.CRITICAL
}
log_level = log_levels[application.config.get("log_level", "info")]
log = logging.getLogger(__name__)
console_formatter = logging.Formatter(
'%(levelname)s\t%(filename)s:%(lineno)d\t\t%(message)s', '%m-%d %H:%M:%S')
file_formatter = logging.Formatter(
'%(levelname)s - %(asctime)s - %(pathname)s - %(lineno)d - %(message)s', '%m-%d %H:%M:%S')
console_handler = logging.StreamHandler()
console_handler.setLevel(log_level)
console_handler.setFormatter(console_formatter)
rotatingfile_handler = RotatingFileHandler('platus.log', maxBytes=10000, backupCount=1)
rotatingfile_handler.setLevel(log_level)
rotatingfile_handler.setFormatter(file_formatter)
application.logger.addHandler(console_handler)
application.logger.addHandler(rotatingfile_handler)
application.logger.setLevel(log_level)
if __name__ == '__main__':
application.run(host="0.0.0.0", port=5001)