Fixed the weird database issue
This commit is contained in:
parent
59281db9cb
commit
2c5ed21011
@ -1,51 +0,0 @@
|
|||||||
from .modules.bootstrap import bootstrap
|
|
||||||
from .modules.csrf import csrf
|
|
||||||
from .modules.db import db
|
|
||||||
from .modules.login_manager import login_manager
|
|
||||||
from .modules.mail import mail
|
|
||||||
from .config import DevelopmentConfig as Config
|
|
||||||
|
|
||||||
from flask import Flask
|
|
||||||
from flask_wtf.csrf import CSRFError
|
|
||||||
from flask.json import jsonify
|
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from .admin.views import admin
|
|
||||||
from .api.views import api
|
|
||||||
from .views import views
|
|
||||||
from .quiz.views import quiz
|
|
||||||
|
|
||||||
def create_app():
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.config.from_object(Config())
|
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto= 1, x_host= 1)
|
|
||||||
|
|
||||||
bootstrap.init_app(app)
|
|
||||||
csrf.init_app(app)
|
|
||||||
db.init_app(app)
|
|
||||||
login_manager.init_app(app)
|
|
||||||
mail.init_app(app)
|
|
||||||
|
|
||||||
login_manager.login_view = 'admin._login'
|
|
||||||
@login_manager.user_loader
|
|
||||||
def _load_user(user_id):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@app.errorhandler(404)
|
|
||||||
def _404_handler(error):
|
|
||||||
return jsonify({'error':'404 — Not Found'}), 404
|
|
||||||
@app.errorhandler(CSRFError)
|
|
||||||
def _csrf_handler():
|
|
||||||
return jsonify({'error':'Could not validate a secure connection.'}), 403
|
|
||||||
@app.context_processor
|
|
||||||
def _now():
|
|
||||||
return {'now': datetime.utcnow()}
|
|
||||||
|
|
||||||
app.register_blueprint(admin, url_prefix='/admin')
|
|
||||||
app.register_blueprint(api, url_prefix='/api')
|
|
||||||
app.register_blueprint(views)
|
|
||||||
app.register_blueprint(quiz)
|
|
||||||
|
|
||||||
return app
|
|
@ -1,4 +1,4 @@
|
|||||||
from . import Config
|
from main import Config
|
||||||
from os import path
|
from os import path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from main import app
|
from main import app, Config
|
||||||
from . import Config
|
|
||||||
from .data import data
|
from .data import data
|
||||||
from .modules.db import db
|
from .modules import db
|
||||||
from .tools.data import save
|
from .tools.data import save
|
||||||
from .tools.logs import write
|
from .tools.logs import write
|
||||||
|
|
||||||
|
10
ref-test/app/modules.py
Normal file
10
ref-test/app/modules.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from flask_bootstrap import Bootstrap
|
||||||
|
bootstrap = Bootstrap()
|
||||||
|
from flask_wtf.csrf import CSRFProtect
|
||||||
|
csrf = CSRFProtect()
|
||||||
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
db = SQLAlchemy()
|
||||||
|
from flask_login import LoginManager
|
||||||
|
login_manager = LoginManager()
|
||||||
|
from flask_mail import Mail
|
||||||
|
mail = Mail()
|
@ -1,2 +0,0 @@
|
|||||||
from flask_bootstrap import Bootstrap
|
|
||||||
bootstrap = Bootstrap()
|
|
@ -1,2 +0,0 @@
|
|||||||
from flask_wtf.csrf import CSRFProtect
|
|
||||||
csrf = CSRFProtect()
|
|
@ -1,2 +0,0 @@
|
|||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
db = SQLAlchemy()
|
|
@ -1,2 +0,0 @@
|
|||||||
from flask_login import LoginManager
|
|
||||||
login_manager = LoginManager()
|
|
@ -1,2 +0,0 @@
|
|||||||
from flask_mail import Mail
|
|
||||||
mail = Mail()
|
|
@ -1,4 +1,4 @@
|
|||||||
from .. import Config
|
from main import Config
|
||||||
from ..data import data as data_dir
|
from ..data import data as data_dir
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from .. import Config
|
from main import Config
|
||||||
from ..data import data
|
from ..data import data
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -1,6 +1,53 @@
|
|||||||
#!/bin/env python
|
from app.modules import bootstrap, csrf, db, login_manager, mail
|
||||||
from app import create_app
|
from app.config import DevelopmentConfig as Config
|
||||||
|
|
||||||
|
from flask import Flask
|
||||||
|
from flask_wtf.csrf import CSRFError
|
||||||
|
from flask.json import jsonify
|
||||||
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from app.admin.views import admin
|
||||||
|
from app.api.views import api
|
||||||
|
from app.views import views
|
||||||
|
from app.quiz.views import quiz
|
||||||
|
|
||||||
|
def create_app():
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config.from_object(Config())
|
||||||
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto= 1, x_host= 1)
|
||||||
|
|
||||||
|
bootstrap.init_app(app)
|
||||||
|
csrf.init_app(app)
|
||||||
|
db.init_app(app)
|
||||||
|
login_manager.init_app(app)
|
||||||
|
mail.init_app(app)
|
||||||
|
|
||||||
|
login_manager.login_view = 'admin._login'
|
||||||
|
@login_manager.user_loader
|
||||||
|
def _load_user(user_id):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def _404_handler(error):
|
||||||
|
return jsonify({'error':'404 — Not Found'}), 404
|
||||||
|
@app.errorhandler(CSRFError)
|
||||||
|
def _csrf_handler():
|
||||||
|
return jsonify({'error':'Could not validate a secure connection.'}), 403
|
||||||
|
@app.context_processor
|
||||||
|
def _now():
|
||||||
|
return {'now': datetime.utcnow()}
|
||||||
|
|
||||||
|
app.register_blueprint(admin, url_prefix='/admin')
|
||||||
|
app.register_blueprint(api, url_prefix='/api')
|
||||||
|
app.register_blueprint(views)
|
||||||
|
app.register_blueprint(quiz)
|
||||||
|
|
||||||
|
return app
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from app.install import install_scripts
|
from app.install import install_scripts
|
||||||
install_scripts()
|
install_scripts()
|
||||||
|
Loading…
Reference in New Issue
Block a user