forked from MikiDi/mu-python-template
-
Notifications
You must be signed in to change notification settings - Fork 11
/
web.py
40 lines (32 loc) · 1.07 KB
/
web.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
import os
from importlib import import_module
import builtins
import flask
from rdflib.namespace import Namespace
import helpers
from escape_helpers import sparql_escape
# WSGI variable name used by the server
app = flask.Flask(__name__)
##################
## Vocabularies ##
##################
mu = Namespace('http://mu.semte.ch/vocabularies/')
mu_core = Namespace('http://mu.semte.ch/vocabularies/core/')
mu_ext = Namespace('http://mu.semte.ch/vocabularies/ext/')
SERVICE_RESOURCE_BASE = 'http://mu.semte.ch/services/'
builtins.app = app
builtins.helpers = helpers
builtins.sparql_escape = sparql_escape
# Import the app from the service consuming the template
app_file = os.environ.get('APP_ENTRYPOINT')
try:
module_path = 'ext.app.{}'.format(app_file)
import_module(module_path)
except Exception:
helpers.logger.exception('Exception raised when importing app code')
#######################
## Start Application ##
#######################
if __name__ == '__main__':
debug = os.environ.get('MODE') == "development"
app.run(debug=debug, host='0.0.0.0', port=80)