-
Notifications
You must be signed in to change notification settings - Fork 184
/
app.py
33 lines (26 loc) · 867 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
import os
import connexion
from injector import Binder
from flask_injector import FlaskInjector
from connexion.resolver import RestyResolver
from services.elasticsearch import ElasticSearchIndex, ElasticSearchFactory
from conf.elasticsearch_mapper import room_mapping
def configure(binder: Binder) -> Binder:
binder.bind(
ElasticSearchIndex,
ElasticSearchIndex(
ElasticSearchFactory(
os.environ['ELASTICSEARCH_HOST'],
os.environ['ELASTICSEARCH_PORT'],
),
'rooms',
'room',
room_mapping
)
)
return binder
if __name__ == '__main__':
app = connexion.App(__name__, specification_dir='swagger/')
app.add_api('indexer.yaml', resolver=RestyResolver('api'))
FlaskInjector(app=app.app, modules=[configure])
app.run(port=9090)