-
Notifications
You must be signed in to change notification settings - Fork 2
/
runner.py
executable file
·66 lines (57 loc) · 1.9 KB
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
#
# This file is part of the Provider API Example.
#
# Copyright (C) 2023 Serghei Iakovlev <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
"""The main entry point for Provider API Example.
To run this entrypoint use any of the following command:
$ flask --app runner:app run
$ python runner.py
$ ./runner.py
"""
import os
from provider.app import create_app, load_env_vars
load_env_vars(os.path.dirname(os.path.abspath(__file__)))
# The application supports different startup modes:
# - development
# - testing
# - production
# - default (alias for development)
#
# To specify an application's startup mode, set the variable
# PRODUCTS_API_CONFIG to an appropriate value as follows:
#
# $ export PRODUCTS_API_CONFIG=production
# $ flask --app runner:app run
#
# Please note: When starting the application with flask script
# (which is by design the way to run an application in development mode),
# the --debug command line flag has nothing to do with the value of
# PRODUCTS_API_CONFIG variable because they are handled differently, by
# different subsystems. Thus, the following way of starting is perfectly
# functional (although it makes no sense):
#
# $ export PRODUCTS_API_CONFIG=production
# $ flask --app runner:app run --debug
#
config = os.getenv('PRODUCTS_API_CONFIG', 'default').lower()
app = create_app(config)
# The alternative way to start the application is through the Flask.run()
# method. This will immediately launch a local server exactly the same way
# the flask script does.
#
# The following code is for starting an application using only
# one of the following launch methods:
#
# $ python runner.py
# $ ./runner.py
#
# It will NOT be executed with the following launch methods:
#
# $ flask --app runner:app run
#
if __name__ == '__main__':
app.run()