Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend_api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
videoag
backend_api
Commits
cc1bbb8c
Commit
cc1bbb8c
authored
11 months ago
by
Simon Künzel
Browse files
Options
Downloads
Patches
Plain Diff
Update initialization. Add warning and some comments.
parent
97b9bd55
No related branches found
No related tags found
1 merge request
!3
Rollout to production
Pipeline
#6025
passed
11 months ago
Stage: build
Stage: test
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/uwsgi_example.ini
+1
-1
1 addition, 1 deletion
config/uwsgi_example.ini
src/api/__init__.py
+2
-1
2 additions, 1 deletion
src/api/__init__.py
src/app.py
+18
-14
18 additions, 14 deletions
src/app.py
src/run_tests.py
+1
-1
1 addition, 1 deletion
src/run_tests.py
with
22 additions
and
17 deletions
config/uwsgi_example.ini
+
1
−
1
View file @
cc1bbb8c
...
...
@@ -9,7 +9,7 @@ socket = /uwsgi/uwsgi.sock
manage-script-name
=
true
chdir
=
./src/
mount
=
/=app:
api_
app
mount
=
/=app:app
need-app
=
true # Fail if startup throws exception
master
=
true # Master manages our workers (in our case, just one worker)
...
...
This diff is collapsed.
Click to expand it.
src/api/__init__.py
+
2
−
1
View file @
cc1bbb8c
# noinspection PyUnresolvedReferences
from
app
import
api_app
as
app
,
api_config
as
config
# We have these here because 'api.config' and 'api.live_config' is nicer than 'app.config' and 'api.live_config.config'
from
app
import
app
,
config
from
api.live_config
import
config
as
live_config
This diff is collapsed.
Click to expand it.
src/app.py
+
18
−
14
View file @
cc1bbb8c
import
locale
if
__name__
==
"
__main__
"
:
print
(
"
You are running app.py as the main file. This is not supported and causes import errors. Execute with
'
flask run
'
instead
"
)
exit
(
-
1
)
import
os
from
flask
import
Flask
,
Config
locale
.
setlocale
(
locale
.
LC_ALL
,
'
de_DE.utf8
'
)
api_app
=
Flask
(
"
api
"
)
api_config
=
api_app
.
config
app
=
Flask
(
"
api
"
)
config
=
app
.
config
api_
config
.
from_pyfile
(
os
.
path
.
join
(
os
.
getcwd
(),
os
.
environ
[
"
VIDEOAG_API_CONFIG
"
]))
config
.
from_pyfile
(
os
.
path
.
join
(
os
.
getcwd
(),
os
.
environ
[
"
VIDEOAG_API_CONFIG
"
]))
if
"
VIDEOAG_API_TEST_CONFIG_OVERRIDE
"
in
os
.
environ
:
override_config
=
Config
(
api_
config
.
root_path
)
override_config
=
Config
(
config
.
root_path
)
override_config
.
from_pyfile
(
os
.
path
.
join
(
os
.
getcwd
(),
os
.
environ
[
"
VIDEOAG_API_TEST_CONFIG_OVERRIDE
"
]))
# Merge the config files manually to also merge dicts (instead of one overwriting the other)
for
key
,
value
in
override_config
.
items
():
if
key
not
in
api_
config
:
api_
config
[
key
]
=
value
if
key
not
in
config
:
config
[
key
]
=
value
continue
if
isinstance
(
value
,
dict
)
and
isinstance
(
api_
config
[
key
],
dict
):
api_
config
[
key
]
|=
value
if
isinstance
(
value
,
dict
)
and
isinstance
(
config
[
key
],
dict
):
config
[
key
]
|=
value
else
:
api_
config
[
key
]
=
value
config
[
key
]
=
value
if
"
SECRET_KEY
"
not
in
api_config
:
api_config
[
"
SECRET_KEY
"
]
=
os
.
urandom
(
24
)
# pragma: no cover
# A key is required for flask (This key is used to sign the cookies)
if
"
SECRET_KEY
"
not
in
config
:
config
[
"
SECRET_KEY
"
]
=
os
.
urandom
(
24
)
# pragma: no cover
# Import routes AFTER initialization
# noinspection PyUnresolvedReferences
import
api.routes
This diff is collapsed.
Click to expand it.
src/run_tests.py
+
1
−
1
View file @
cc1bbb8c
...
...
@@ -3,7 +3,7 @@
if
__name__
==
'
__main__
'
:
import
app
import
unittest
app
.
api_
app
.
testing
=
True
app
.
app
.
testing
=
True
# This is always run from src/
suite
=
unittest
.
defaultTestLoader
.
discover
(
"
../tests/
"
,
pattern
=
"
*
"
,
top_level_dir
=
"
../tests
"
)
if
not
unittest
.
TextTestRunner
(
verbosity
=
2
,
failfast
=
True
).
run
(
suite
).
wasSuccessful
():
...
...
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