forked from WorkshopDudes/elasticsearch-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (20 loc) · 647 Bytes
/
Copy pathapp.py
File metadata and controls
29 lines (20 loc) · 647 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import logging
from flask import Flask
import config
from elasticsearch import Elasticsearch
def create_app():
flask_app = Flask(__name__)
config.configure_app(flask_app)
elasticsearch_url = flask_app.config['ELASTICSEARCH_URL']
flask_app.elasticsearch = Elasticsearch(hosts=[elasticsearch_url])
return flask_app
app = create_app()
if not app.debug:
stream_handler = logging.StreamHandler()
app.logger.addHandler(stream_handler)
if __name__ == "__main__":
port = int(os.environ.get('PORT', 80))
app.run(host='0.0.0.0', port=port, debug=True)