-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
41 lines (31 loc) · 961 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
39
40
41
from loader import *
from flask import Flask, render_template, request, jsonify, url_for
from flask.ext.bower import Bower
from bokeh.protocol import serialize_json
import os
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
bower = Bower(app)
workspace = {}
@app.route('/')
def hello_world():
return render_template( 'index.html' )
@app.route('/blaze', methods=['POST'])
def blaze_to_data():
global workspace
workspace = parse_blaze_manifest_with_loader( request.data.decode('utf-8') )
return jsonify(
keys = list( workspace.keys() ),
)
@app.route('/bokeh', methods=['POST'])
def bokeh_to_data():
bk_plot = parse_bokeh_manifest_with_loader( request.data.decode('utf-8') )
print(bk_plot)
return jsonify(
all_models = serialize_json( bk_plot.dump() ),
ref = bk_plot.ref,
)
# run the app
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
app.run( port=port)