forked from Qwant/idunn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (28 loc) · 930 Bytes
/
app.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
from apistar import App, Include
from idunn.utils.settings import SettingsComponent
from idunn.utils.index_names import IndexNamesSettingsComponent
from idunn.utils.es_wrapper import ElasticSearchComponent
from idunn.utils.logging import init_logging, LogErrorHook
from idunn.utils.cors import CORSHeaders
from idunn.api.urls import get_api_urls
from apistar_prometheus import PrometheusComponent, PrometheusHooks
settings = SettingsComponent('IDUNN')
init_logging(settings)
routes = [
Include('/v1', name='v1', routes=get_api_urls(settings)),
]
components = [
settings,
ElasticSearchComponent(),
IndexNamesSettingsComponent(),
PrometheusComponent()
]
event_hooks = [LogErrorHook(), CORSHeaders, PrometheusHooks()]
app = App(
routes=routes,
schema_url='/schema',
components=components,
event_hooks=event_hooks
)
if __name__ == '__main__':
app.serve('127.0.0.1', 5000, debug=True)