forked from luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (40 loc) · 1.57 KB
/
main.py
File metadata and controls
55 lines (40 loc) · 1.57 KB
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
# Copyright 2015 The LUCI Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.
import os
import sys
APP_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(APP_DIR, 'components', 'third_party'))
import endpoints
import webapp2
from components import utils
from components import ereporter2
from components import template
from google.appengine.api import app_identity
import admin
import api
import handlers
def bootstrap_templates():
TEMPLATES_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'templates')
template.bootstrap(
{'templates': TEMPLATES_DIR},
global_env={
'hostname': app_identity.get_default_version_hostname()
})
def create_html_app(): # pragma: no cover
"""Returns WSGI app that serves HTML pages."""
return webapp2.WSGIApplication(
handlers.get_frontend_routes(), debug=utils.is_local_dev_server())
def create_endpoints_app(): # pragma: no cover
"""Returns WSGI app that serves cloud endpoints requests."""
return endpoints.api_server([api.ConfigApi, admin.AdminApi])
def create_backend_app(): # pragma: no cover
"""Returns WSGI app for backend."""
bootstrap_templates()
return webapp2.WSGIApplication(
handlers.get_backend_routes(), debug=utils.is_local_dev_server())
def initialize(): # pragma: no cover
"""Bootstraps the global state and creates WSGI applications."""
ereporter2.register_formatter()
return create_html_app(), create_endpoints_app(), create_backend_app()