Skip to content
Snippets Groups Projects

:ambulance: Fix usrbin info

Merged Carlos Brito requested to merge fix-usrbin-info into develop
3 files
+ 49
13
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 26
7
""".. moduleauthor:: Carlos Brito"""
from flask import Flask
from flask import Flask, request, jsonify
from dotenv import load_dotenv
from flask_cors import CORS
import os
@@ -21,21 +21,32 @@ def create_app(test_config=None):
if app.debug or app.testing:
load_dotenv(".env.local")
CORS(
app,
# resources={
# r"/*": {
# "origins": ["http://127.0.0.1:5000", "http://localhost:8080", "https://simrad.cern.ch"],
# "allow_credentials": True,
# "methods": ["GET", "POST", "DELETE", "PUT", "OPTIONS"],
# }
# },
supports_credentials=True,
)
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
app.config['SESSION_COOKIE_SECURE'] = True
CORS(app)
from .auth import oauth
oauth.init_app(app)
if not app.testing:
from . import logger
logger.setup_logging(app)
# if not app.testing:
# from . import logger
# logger.setup_logging(app)
from . import auth
from . import index
app.register_blueprint(auth.bp)
app.register_blueprint(auth.bp, url_prefix="/auth")
app.register_blueprint(index.bp)
# DISCLAIMER: programmer responsability to make sure that all dash ids
@@ -59,5 +70,13 @@ def create_app(test_config=None):
# app.route, while giving the blog blueprint a url_prefix, but for
# the tutorial the blog will be the main index
#app.add_url_rule("/", endpoint="index")
@app.before_request
def before_request():
headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
}
if request.method.lower() == "options":
return jsonify(headers), 200
return app
Loading