51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
from flask import Flask, g
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_migrate import Migrate
|
|
from flask_login import LoginManager
|
|
from config import Config
|
|
import time
|
|
|
|
app = Flask(__name__)
|
|
app.config.from_object(Config)
|
|
|
|
# Check security of secret
|
|
if Config.SECRET_KEY == "a-random-secret-key":
|
|
raise Exception("Please use a strong secret key!")
|
|
|
|
db = SQLAlchemy(app)
|
|
migrate = Migrate(app, db)
|
|
|
|
login = LoginManager(app)
|
|
login.login_view = 'login'
|
|
login.login_message = "Veuillez vous authentifier avant de continuer."
|
|
|
|
from app.utils.converters import *
|
|
app.url_map.converters['topicslug'] = TopicSlugConverter
|
|
app.url_map.converters['forum'] = ForumConverter
|
|
|
|
|
|
@app.before_request
|
|
def request_time():
|
|
g.request_start_time = time.time()
|
|
g.request_time = lambda: "%.5fs" % (time.time() - g.request_start_time)
|
|
|
|
|
|
from app.processors.menu import menu_processor
|
|
from app.processors.utilities import utilities_processor
|
|
|
|
from app import models # IDK why this is here, but it works
|
|
from app.models.comment import Comment
|
|
from app.models.thread import Thread
|
|
from app.models.forum import Forum
|
|
from app.models.topic import Topic
|
|
from app.models.notification import Notification
|
|
|
|
from app.routes import index, search, users, tools # To load routes at initialization
|
|
from app.routes.account import login, account, notification
|
|
from app.routes.admin import index, groups, account, trophies, forums
|
|
from app.routes.forum import index, topic
|
|
|
|
from app.utils import pluralize # To use pluralize into the templates
|
|
from app.utils import date
|
|
from app.utils import is_title
|