2011-10-15 02:24:02 +02:00
|
|
|
from web import main, db, mail
|
2011-09-11 22:11:36 +02:00
|
|
|
from api import api
|
2011-10-13 21:27:56 +02:00
|
|
|
import os
|
2011-09-09 21:21:37 +02:00
|
|
|
|
|
|
|
from flask import *
|
2011-10-15 02:24:02 +02:00
|
|
|
from flaskext.babel import Babel
|
2011-09-09 21:21:37 +02:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object("default_settings")
|
2011-10-13 21:27:56 +02:00
|
|
|
|
2011-09-09 21:21:37 +02:00
|
|
|
app.register_blueprint(main)
|
2011-09-11 22:11:36 +02:00
|
|
|
app.register_blueprint(api)
|
2011-09-09 21:21:37 +02:00
|
|
|
|
|
|
|
# db
|
|
|
|
db.init_app(app)
|
|
|
|
db.app = app
|
|
|
|
db.create_all()
|
|
|
|
|
|
|
|
# mail
|
|
|
|
mail.init_app(app)
|
|
|
|
|
2011-10-15 01:19:19 +02:00
|
|
|
# translations
|
2011-10-15 02:24:02 +02:00
|
|
|
babel = Babel(app)
|
2011-10-15 01:19:19 +02:00
|
|
|
|
|
|
|
@babel.localeselector
|
|
|
|
def get_locale():
|
2011-10-16 23:38:27 +02:00
|
|
|
lang = request.accept_languages.best_match(['fr', 'en'])
|
|
|
|
setattr(g, 'lang', lang)
|
|
|
|
return lang
|
2011-10-15 01:19:19 +02:00
|
|
|
|
2011-09-09 21:21:37 +02:00
|
|
|
def main():
|
|
|
|
app.run(host="0.0.0.0", debug=True)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|