Mercurial > cgi-bin > hgwebdir.cgi > POP > oldRepo
view 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 source
1 from bottle import route, run, template, response
2 import urllib
4 graphFile = None
6 #==============
8 @route('/startsavinggraph')
9 def startsavinggraph():
10 global graphFile
11 graphFile = open("syntaxGraph.json", "w")
12 print "opened graph file "
13 print "Name of the file: ", graphFile.name
14 print "Closed or not : ", graphFile.closed
15 print "Opening mode : ", graphFile.mode
16 print "Softspace flag : ", graphFile.softspace
17 response.set_header('Access-Control-Allow-Origin', '*')
19 @route('/save1elem/<thejson>')
20 def save1elem(thejson):
21 thejson = thejson.replace('%T', '\t')
22 thejson = thejson.replace('%N', '\n')
23 thejson = thejson.replace('%H', '\\')
24 thejson = thejson.replace('%S', '/')
25 # print thejson
26 global graphFile
27 graphFile.write("%s\nend elem\n" % thejson)
28 response.set_header('Access-Control-Allow-Origin', '*')
30 @route('/endsavinggraph')
31 def endsavinggraph():
32 global graphFile
33 response.set_header('Access-Control-Allow-Origin', '*')
34 graphFile.close()
35 return 'ACK'
37 #================
39 @route('/startretrievinggraph')
40 def startretrievinggraph():
41 global graphFile
42 graphFile = open("syntaxGraph.json", "r")
43 response.set_header('Access-Control-Allow-Origin', '*')
44 return 'ACK'
46 @route('/get1elem')
47 def get1elem():
48 global graphFile
49 returnjson = graphFile.readline()
50 response.set_header('Access-Control-Allow-Origin', '*')
51 return returnjson
53 @route('/endretrievinggraph')
54 def endretrievinggraph():
55 global graphFile
56 response.set_header('Access-Control-Allow-Origin', '*')
57 graphFile.close()
58 return 'ACK'
60 #================
62 run(host='localhost', port=8080)
