-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathremote_main.py
More file actions
38 lines (29 loc) · 915 Bytes
/
remote_main.py
File metadata and controls
38 lines (29 loc) · 915 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
30
31
32
33
34
35
36
37
38
from flask import Flask
from flask.json import JSONEncoder
import atexit
# import cf_deployment_tracker
import os
from flask_cors import CORS
from db import db_setup
# Emit Bluemix deployment event
# //deprecated//
# cf_deployment_tracker.track()
app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})
db_setup(app)
class CustomJSONEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
return JSONEncoder.default(self, obj)
app.json_encoder = CustomJSONEncoder
from routes import *
# On Bluemix, get the port number from the environment variable PORT
# When running this app on the local machine, default the port to 8000
port = int(os.getenv('PORT', 9000))
@atexit.register
def shutdown():
if app.db_client:
app.db_client.disconnect()
if __name__ == '__main__':
app.run(host='0.0.0.0', port=port, debug=True)