Dockerised. Restructured to remove circular import
Moved most of app definitions out of guard function to use wsgi Updated configuration files and referencing of .env values. Local version needs dotenv or exporting of env variables. Dockerised version works fine without load_dotenv. Ready to test now!
This commit is contained in:
@@ -10,32 +10,11 @@ from flask_wtf.csrf import CSRFProtect, CSRFError
|
||||
from flask_mail import Mail
|
||||
|
||||
from common.security import check_keyfile_exists, generate_keyfile
|
||||
import config
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object('config.DevelopmentConfig')
|
||||
|
||||
Bootstrap(app)
|
||||
csrf = CSRFProtect(app)
|
||||
|
||||
@app.errorhandler(CSRFError)
|
||||
def csrf_error_handler(error):
|
||||
return jsonify({ 'error': 'Could not validate a secure connection.'} ), 400
|
||||
|
||||
try:
|
||||
mongo = MongoClient(app.config['MONGO_URI'])
|
||||
db = mongo[app.config['MONGO_INITDB_DATABASE']]
|
||||
except ConnectionFailure as error:
|
||||
print(error)
|
||||
|
||||
try:
|
||||
mail = Mail(app)
|
||||
except Exception as error:
|
||||
print(error)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if not check_keyfile_exists():
|
||||
generate_keyfile()
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(config.TestingConfig())
|
||||
|
||||
from common.blueprints import cookie_consent
|
||||
|
||||
@@ -80,5 +59,23 @@ if __name__ == '__main__':
|
||||
@app.errorhandler(404)
|
||||
def _404_handler(e):
|
||||
return render_template('/quiz/404.html'), 404
|
||||
|
||||
@app.errorhandler(CSRFError)
|
||||
def csrf_error_handler(error):
|
||||
return jsonify({ 'error': 'Could not validate a secure connection.'} ), 400
|
||||
|
||||
if not check_keyfile_exists():
|
||||
generate_keyfile()
|
||||
|
||||
Bootstrap(app)
|
||||
csrf = CSRFProtect(app)
|
||||
|
||||
return app
|
||||
|
||||
app = create_app()
|
||||
mongo = MongoClient(app.config['MONGO_URI'])
|
||||
db = mongo[app.config['MONGO_INITDB_DATABASE']]
|
||||
mail = Mail(app)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host=app.config['APP_HOST'])
|
Reference in New Issue
Block a user