forked from yeatmanlab/AFQ-Browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
45 lines (37 loc) · 1.43 KB
/
server.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
42
43
44
45
__author__ = 'kjordan'
import cherrypy
import json
from glob import glob
import os
from streamlines import *
class HelloWorld(object):
@cherrypy.expose
def index(self):
return "Hello world!"
@cherrypy.expose
@cherrypy.tools.json_out()
@cherrypy.tools.json_in()
def generate(self):
result = {"operation": "request", "result": "success"}
trkpath = '/Users/kjordan/repos/AFQ-viz/client/data/test_ExCap_L.trk'
sls = loadtrkfile(trkpath)
jsls = makejsontrk(sls)
clusters = executeclustering(sls, dist_metric=50)
jcsls = makejsonclusters(clusters)
#clusters = executeclustering(trkpath, 35, 5)
#savejson(clusters, '/Users/kjordan/repos/AFQ-viz/client/data/testingslfcpy.json', 15)
#makejsonclusters(clusters)
input_json = cherrypy.request.json #this is the user information
#value = input_json #["my_key"]
#value["my_key"] = 'this comes from client'
#value["my_key"] = jsls
output_json = jcsls
#All responses are serialized to JSON. This the same as
#return simplejson.dumps(result)
#print("incoming data is", input_json)
#input_json["new_thing"] = executeclustering(value["my_key"])
return output_json
if __name__ == '__main__':
cherrypy.quickstart(HelloWorld(), "/", "Hello.config")
#cherrypy.config.update({'server.socket_port': 8090})
#cherrypy.engine.restart()