Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
get_start_flask
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Ishan Patel
get_start_flask
Commits
ae806598
Commit
ae806598
authored
7 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Updated to prevent loading config file in production
parent
dec9b015
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/__init__.py
+11
-3
11 additions, 3 deletions
app/__init__.py
with
11 additions
and
3 deletions
app/__init__.py
+
11
−
3
View file @
ae806598
...
@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy
...
@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy
from
flask_login
import
LoginManager
from
flask_login
import
LoginManager
from
flask_migrate
import
Migrate
from
flask_migrate
import
Migrate
from
flask_bootstrap
import
Bootstrap
from
flask_bootstrap
import
Bootstrap
import
os
# local imports
# local imports
from
config
import
app_config
from
config
import
app_config
...
@@ -13,9 +14,16 @@ db = SQLAlchemy()
...
@@ -13,9 +14,16 @@ db = SQLAlchemy()
login_manager
=
LoginManager
()
login_manager
=
LoginManager
()
def
create_app
(
config_name
):
def
create_app
(
config_name
):
app
=
Flask
(
__name__
,
instance_relative_config
=
True
)
if
os
.
getenv
(
'
FLASK_ENV
'
)
==
"
production
"
:
app
.
config
.
from_object
(
app_config
[
config_name
])
app
=
Flask
(
__name__
)
app
.
config
.
from_pyfile
(
'
config.py
'
)
app
.
config
.
update
(
SECRET_KEY
=
os
.
getenv
(
'
SECRET_KEY
'
),
SQLALCHEMY_DATABASE_URI
=
os
.
getenv
(
'
SQLALCHEMY_DATABASE_URI
'
)
)
else
:
app
=
Flask
(
__name__
,
instance_relative_config
=
True
)
app
.
config
.
from_object
(
app_config
[
config_name
])
app
.
config
.
from_pyfile
(
'
config.py
'
)
db
.
init_app
(
app
)
db
.
init_app
(
app
)
login_manager
.
init_app
(
app
)
login_manager
.
init_app
(
app
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment