blob: 838626409052f72ab69b1457d49b94e75e1740c6 (
plain)
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
|
# required imports and code exection for basic functionning
import os
import sys
if 'threading' in sys.modules:
raise Exception('threading module loaded before patching!')
import conf
import logging
if not (conf.WEBSERVER_DEBUG or conf.ON_HEROKU):
import gevent.monkey
gevent.monkey.patch_thread()
def set_logging(log_path, log_level=logging.DEBUG,
log_format='%(asctime)s %(levelname)s %(message)s'):
logger = logging.getLogger('pyaggr3g470r')
formater = logging.Formatter(log_format)
handler = logging.FileHandler(log_path)
handler.setFormatter(formater)
logger.addHandler(handler)
logger.setLevel(log_level)
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
# Create Flask application
application = Flask('pyaggr3g470r')
application.debug = conf.WEBSERVER_DEBUG
set_logging(conf.LOG_PATH, log_level=logging.DEBUG if conf.WEBSERVER_DEBUG
else logging.INFO)
# Create dummy secrey key so we can use sessions
application.config['SECRET_KEY'] = getattr(conf, 'WEBSERVER_SECRET', None)
if not application.config['SECRET_KEY']:
application.config['SECRET_KEY'] = os.urandom(12)
application.config['SQLALCHEMY_DATABASE_URI'] = conf.SQLALCHEMY_DATABASE_URI
application.config['RECAPTCHA_USE_SSL'] = True
application.config['RECAPTCHA_PUBLIC_KEY'] = conf.RECAPTCHA_PUBLIC_KEY
application.config['RECAPTCHA_PRIVATE_KEY'] = conf.RECAPTCHA_PRIVATE_KEY
db = SQLAlchemy(application)
|