2017-02-10 06:10:44 +01:00
|
|
|
from config import config
|
|
|
|
from database import db
|
2017-03-25 08:52:56 +01:00
|
|
|
from flask import Flask, render_template, request, session, url_for, redirect, jsonify
|
2017-04-08 01:31:08 +02:00
|
|
|
from flask_sslify import SSLify
|
2017-06-13 03:39:49 +02:00
|
|
|
from titanembeds.utils import rate_limiter, discord_api, bot_alive
|
2017-02-10 06:10:44 +01:00
|
|
|
import blueprints.api
|
2017-03-24 09:22:03 +01:00
|
|
|
import blueprints.user
|
2017-07-06 23:35:08 +02:00
|
|
|
import blueprints.admin
|
2017-03-26 06:14:42 +02:00
|
|
|
import blueprints.embed
|
2017-02-10 06:10:44 +01:00
|
|
|
import os
|
2017-07-06 23:35:08 +02:00
|
|
|
from titanembeds import devs
|
2017-02-10 06:10:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
os.chdir(config['app-location'])
|
2017-03-25 08:52:56 +01:00
|
|
|
app = Flask(__name__, static_folder="static")
|
2017-06-10 05:21:44 +02:00
|
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = config['database-uri'] + "?charset=utf8mb4"
|
2017-02-10 06:10:44 +01:00
|
|
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # Suppress the warning/no need this on for now.
|
2017-04-04 07:53:27 +02:00
|
|
|
app.config['RATELIMIT_HEADERS_ENABLED'] = True
|
2017-04-08 03:37:45 +02:00
|
|
|
app.config['SQLALCHEMY_POOL_RECYCLE'] = 250
|
2017-04-24 08:02:03 +02:00
|
|
|
app.config['RATELIMIT_STORAGE_URL'] = 'keyvalprops://'
|
2017-02-10 06:10:44 +01:00
|
|
|
app.secret_key = config['app-secret']
|
|
|
|
|
|
|
|
db.init_app(app)
|
2017-03-27 01:37:27 +02:00
|
|
|
rate_limiter.init_app(app)
|
2017-04-08 01:31:08 +02:00
|
|
|
sslify = SSLify(app, permanent=True)
|
2017-02-10 06:10:44 +01:00
|
|
|
|
|
|
|
app.register_blueprint(blueprints.api.api, url_prefix="/api", template_folder="/templates")
|
2017-07-06 23:35:08 +02:00
|
|
|
app.register_blueprint(blueprints.admin.admin, url_prefix="/admin", template_folder="/templates")
|
2017-03-24 09:22:03 +01:00
|
|
|
app.register_blueprint(blueprints.user.user, url_prefix="/user", template_folder="/templates")
|
2017-03-26 06:14:42 +02:00
|
|
|
app.register_blueprint(blueprints.embed.embed, url_prefix="/embed", template_folder="/templates")
|
2017-02-10 06:10:44 +01:00
|
|
|
|
|
|
|
@app.route("/")
|
2017-03-25 08:52:56 +01:00
|
|
|
def index():
|
2017-03-26 05:31:47 +02:00
|
|
|
return render_template("index.html.j2")
|
2017-04-24 20:55:09 +02:00
|
|
|
|
2017-05-11 04:12:26 +02:00
|
|
|
@app.route("/about")
|
|
|
|
def about():
|
|
|
|
return render_template("about.html.j2")
|
|
|
|
|
2017-04-24 20:55:09 +02:00
|
|
|
@app.before_request
|
|
|
|
def before_request():
|
2017-04-25 04:57:00 +02:00
|
|
|
db.create_all()
|
2017-04-24 20:55:09 +02:00
|
|
|
discord_api.init_discordrest()
|
2017-06-13 03:39:49 +02:00
|
|
|
|
|
|
|
@app.context_processor
|
|
|
|
def context_processor():
|
|
|
|
bot_status = bot_alive()
|
2017-07-06 23:35:08 +02:00
|
|
|
return {"bot_status": bot_status, "devs": devs}
|