-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflaskServer.py
More file actions
40 lines (35 loc) · 1.23 KB
/
flaskServer.py
File metadata and controls
40 lines (35 loc) · 1.23 KB
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
#!/usr/bin/env python
#from werkzeug.contrib.profiler import ProfilerMiddleware
from flask import Flask, request, jsonify, Response
import json
from designs import *
# design = Nautilus3()
# design = Nautilus()
# design = Nautilus2()
# design = SpiraleyHolePanel()
# design = AlienSpineCircuitTraces()
# design = MultiDesign(ThreeArmThinSpiral, 10, 1)
# design = ThreeSidedPointyThing()
# design = TestDesign()
# design = MultiDesign(Chand2, 6, 1)
design = branchThing()
#design = Chand2()
#design = Something()
flaskApp = Flask(__name__, static_folder='jsGui', static_url_path='/jsGui')
@flaskApp.route('/')
def jsGui():
return flaskApp.send_static_file('index.htm')
@flaskApp.route('/getData', methods =['GET', 'POST'])
def getData():
return jsonify(design.getCurrentStateData())
@flaskApp.route('/doCommand', methods =['POST'])
def doCommand():
requestData = json.loads(request.data)
command = requestData.pop(0)
function = getattr(design, command)
return jsonify({'command' : command, 'result' : function(*requestData)})
if __name__ == '__main__':
# flaskApp.config['PROFILE'] = True
# flaskApp.wsgi_app = ProfilerMiddleware(flaskApp.wsgi_app, restrictions=[30])
# flaskApp.run(debug = True, port=80)
flaskApp.run(debug = True, port=80)