-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
69 lines (59 loc) · 2.03 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
import jinja_filters
import pycountry
import pytz
from flask import Flask, g, session, url_for, redirect
#from flask_debugtoolbar import DebugToolbarExtension
from flask_mail import Mail
from flask_sqlalchemy import SQLAlchemy
from geoip import geolite2
from lxml.html.clean import Cleaner
from server import run_server
# Create and initialize app
app = Flask(__name__)
app.jinja_env.filters['pretty_date'] = jinja_filters.pretty_date
app.jinja_env.filters['supress_none'] = jinja_filters.supress_none
app.jinja_env.filters['none_to_zero'] = jinja_filters.none_to_zero
app.jinja_env.auto_reload = True
app.debug = True
app.config.from_object(__name__)
mail = Mail(app)
html_cleaner = Cleaner(page_structure=True, links=False, embedded=False)
# Load default config and override config from an environment variable
app.config.update(dict(
SQLALCHEMY_DATABASE_URI='postgresql://devmsx-centercom:[email protected]/devmsx-centercom',
SQLALCHEMY_ECHO=True,
MAIL_SERVER='192.168.1.200',
DEFAULT_MAIL_SENDER='[email protected]',
SECRET_KEY='e620f0121309a360fc596c481efd895da1c19b1e9358e87a',
SERVER_NAME='dev.msx-center.com',
MAX_CONTENT_LENGTH=32*1024*1024
))
app.config.from_envvar('MSXCENTER_SETTINGS', silent=True)
db = SQLAlchemy(app)
#toolbar = DebugToolbarExtension(app)
# Create ordered lists of countries and timezones
country_list = sorted(pycountry.countries, key = lambda c: c.name)
timezone_list = sorted(pytz.common_timezones)
#######################
## APPLICATION SETUP ##
#######################
# Create test user
@app.before_first_request
def create_database_tables():
db.create_all()
from models import *
from routes import *
from routes.account import *
from routes.lounges import *
from routes.member import *
from routes.news import *
from routes.articles import *
from routes.admin import *
from routes.votes import *
from routes.errors import *
from routes.subscriptions import *
#################################
## NON-SERVICEABLE PARTS BELOW ##
#################################
if __name__ == '__main__':
run_server(app)