Mercurial > cgi-bin > hgwebdir.cgi > POP > oldRepo
diff 1__Development/6__Website/POPBottleServer/POPBottleServer.py @ 7:20a1407463a0
sort of working with view sets -- does restore, (not tested) have to chg Display to handle view sets
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 07 Aug 2014 00:10:50 -0700 |
| parents | d18eee376f45 |
| children | cc10d99e3f83 |
line diff
1.1 --- a/1__Development/6__Website/POPBottleServer/POPBottleServer.py Wed Aug 06 00:16:19 2014 -0700 1.2 +++ b/1__Development/6__Website/POPBottleServer/POPBottleServer.py Thu Aug 07 00:10:50 2014 -0700 1.3 @@ -3,40 +3,18 @@ 1.4 1.5 graphFile = None 1.6 1.7 -@route('/') 1.8 -def index(): 1.9 - return '<b>Hello</b>!' 1.10 +#============== 1.11 1.12 -@route('/<name>') 1.13 -@route('/hello/<name>') 1.14 -def nameroute(name): 1.15 - return template('<b>Hello {{name}}</b>!', name=name) 1.16 - 1.17 -@route('/savejson/<thejson>') 1.18 -def savejson(thejson): 1.19 - text_file = open("syntaxGraph.json", "w") 1.20 - text_file.write("%s" % thejson) 1.21 - text_file.close() 1.22 - print "hello" 1.23 - response.set_header('Access-Control-Allow-Origin', '*') 1.24 -# return 'Got JSON!' 1.25 -# return template('Got JSON! {{printjson}}</b>!', printjson = thejson) 1.26 - 1.27 -@route('/getjson') 1.28 -def getjson(): 1.29 - text_file = open("syntaxGraph.json", "r") 1.30 - returnjson = text_file.read() 1.31 - text_file.close() 1.32 - response.set_header('Access-Control-Allow-Origin', '*') 1.33 - return returnjson 1.34 - 1.35 -#=============== 1.36 @route('/startsavinggraph') 1.37 def startsavinggraph(): 1.38 - global graphFile 1.39 - graphFile = open("syntaxGraph.json", "w") 1.40 - response.set_header('Access-Control-Allow-Origin', '*') 1.41 - return 'ACK' 1.42 + global graphFile 1.43 + graphFile = open("syntaxGraph.json", "w") 1.44 + print "opened graph file " 1.45 + print "Name of the file: ", graphFile.name 1.46 + print "Closed or not : ", graphFile.closed 1.47 + print "Opening mode : ", graphFile.mode 1.48 + print "Softspace flag : ", graphFile.softspace 1.49 + response.set_header('Access-Control-Allow-Origin', '*') 1.50 1.51 @route('/save1elem/<thejson>') 1.52 def save1elem(thejson): 1.53 @@ -44,11 +22,10 @@ 1.54 thejson = thejson.replace('%N', '\n') 1.55 thejson = thejson.replace('%H', '\\') 1.56 thejson = thejson.replace('%S', '/') 1.57 - print thejson 1.58 +# print thejson 1.59 global graphFile 1.60 - graphFile.write("%s\n<end elem>\n" % thejson) 1.61 + graphFile.write("%s\nend elem\n" % thejson) 1.62 response.set_header('Access-Control-Allow-Origin', '*') 1.63 - return 'ACK' 1.64 1.65 @route('/endsavinggraph') 1.66 def endsavinggraph(): 1.67 @@ -80,4 +57,7 @@ 1.68 graphFile.close() 1.69 return 'ACK' 1.70 1.71 +#================ 1.72 + 1.73 run(host='localhost', port=8080) 1.74 +
