Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
frozen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
CSE6
frozen
Commits
cd4ced89
Commit
cd4ced89
authored
2 years ago
by
Arno Wunderlich
Browse files
Options
Downloads
Patches
Plain Diff
initial setup of flask application
parent
af2c9b5c
No related branches found
No related tags found
1 merge request
!5
Db init
Pipeline
#13323
passed
2 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tjts5901/__init__.py
+7
-0
7 additions, 0 deletions
src/tjts5901/__init__.py
src/tjts5901/app.py
+23
-6
23 additions, 6 deletions
src/tjts5901/app.py
with
30 additions
and
6 deletions
src/tjts5901/__init__.py
+
7
−
0
View file @
cd4ced89
...
...
@@ -6,7 +6,14 @@ JYU TJTS5901 Course project
from
importlib_metadata
import
(
PackageNotFoundError
,
version
)
from
.app
import
create_app
try
:
__version__
=
version
(
__name__
)
except
PackageNotFoundError
:
__version__
=
"
unknown
"
__all__
=
[
"
create_app
"
,
"
__version__
"
,
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/tjts5901/app.py
+
23
−
6
View file @
cd4ced89
...
...
@@ -8,6 +8,7 @@ Flask tutorial: https://flask.palletsprojects.com/en/2.2.x/tutorial/
"""
from
os
import
environ
import
os
from
typing
import
Dict
,
Optional
from
dotenv
import
load_dotenv
...
...
@@ -29,15 +30,31 @@ def create_app(config: Optional[Dict] = None) -> Flask:
"""
flask_app
=
Flask
(
__name__
,
instance_relative_config
=
True
)
if
config
:
flask_app
.
config
.
from_mapping
(
SECRET_KEY
=
'
dev
'
,
BRAND
=
"
Hill Valley DMC dealership
"
,
)
# load the instance config, if it exists, when not testing
if
config
is
None
:
flask_app
.
config
.
from_pyfile
(
'
config.py
'
,
silent
=
True
)
else
:
flask_app
.
config
.
from_mapping
(
config
)
# Set flask config variable for "rich" loggin from environment variable.
flask_app
.
config
.
from_envvar
(
"
RICH_LOGGING
"
,
silent
=
True
)
# ensure the instance folder exists
try
:
os
.
makedirs
(
flask_app
.
instance_path
)
except
OSError
:
pass
# Initialize the database connection.
init_db
(
flask_app
)
# a simple page that says hello
@flask_app.route
(
'
/hello
'
)
def
hello
():
return
'
Hello, World!
'
# Register blueprints
from
.
import
views
# pylint: disable=import-outside-toplevel
flask_app
.
register_blueprint
(
views
.
bp
,
url_prefix
=
''
)
return
flask_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