forked from luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_frontend.py
50 lines (36 loc) · 1.38 KB
/
main_frontend.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
# Copyright 2014 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""This modules is imported by AppEngine and defines the 'app' object.
It is a separate file so that application bootstrapping code like ereporter2,
that shouldn't be done in unit tests, can be done safely. This file must be
tested via a smoke test.
"""
import os
import sys
import endpoints
import gae_ts_mon
APP_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(APP_DIR, 'components', 'third_party'))
from components import auth
from components import ereporter2
from components import utils
import config
import handlers_frontend
import handlers_endpoints_v1
def create_application():
ereporter2.register_formatter()
# App that serves HTML pages and old API.
frontend = handlers_frontend.create_application(False)
def is_enabled_callback():
return config.settings().enable_ts_monitoring
gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
# App that serves new endpoints API.
api = endpoints.api_server([
handlers_endpoints_v1.IsolateService,
# components.config endpoints for validation and configuring of
# luci-config service URL.
config.ConfigApi,
])
return frontend, api
frontend_app, endpoints_app = create_application()