mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-28 13:53:12 +00:00
Updated Highscore server
This commit is contained in:
parent
3c3b6b8b23
commit
e7bbb02aba
26 changed files with 1023 additions and 321 deletions
50
Highscore-Server/server/__init__.py
Normal file
50
Highscore-Server/server/__init__.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
from random import randint
|
||||
from flask import Flask, render_template, abort
|
||||
from flask_assets import Bundle
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from server.extensions import db, migrate, cache, assets, login_manager
|
||||
from server.models import Users
|
||||
from server import views, auth, api
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_pyfile('config.py')
|
||||
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
login_manager.init_app(app)
|
||||
login_manager.login_view = "auth.auth"
|
||||
|
||||
assets.init_app(app)
|
||||
|
||||
scripts = Bundle("js/*.js", filters="jsmin", output="gen/scripts.js", depends="js/*.js")
|
||||
assets.register("scripts", scripts)
|
||||
|
||||
styles = Bundle("sass/style.sass", filters="libsass, cssmin", output="gen/styles.css", depends="sass/*.sass")
|
||||
assets.register("styles", styles)
|
||||
|
||||
cache.init_app(app)
|
||||
app.register_blueprint(views.blueprint)
|
||||
app.register_blueprint(auth.blueprint)
|
||||
app.register_blueprint(api.blueprint)
|
||||
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
return Users.query.filter_by(alt_id=user_id).first()
|
||||
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
def error_page(err):
|
||||
if not isinstance(err, HTTPException):
|
||||
abort(500)
|
||||
return (
|
||||
render_template("error.html",
|
||||
error=err.code,
|
||||
msg=err.description,
|
||||
image=str(randint(1, 3))),
|
||||
err.code,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue