Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simrad-flask
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lhcb-fence
simrad-flask
Merge requests
!58
Fix usrbin info
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix usrbin info
fix-usrbin-info
into
develop
Overview
0
Commits
2
Pipelines
2
Changes
3
Merged
Carlos Brito
requested to merge
fix-usrbin-info
into
develop
1 month ago
Overview
0
Commits
2
Pipelines
2
Changes
3
Expand
0
0
Merge request reports
Compare
develop
version 1
2be2818c
1 month ago
develop (base)
and
latest version
latest version
6feea2f6
2 commits,
1 month ago
version 1
2be2818c
1 commit,
1 month ago
3 files
+
49
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
simrad_server/__init__.py
+
26
−
7
Options
"""
.. 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