Mercurial > cgi-bin > hgwebdir.cgi > POP > oldRepo
comparison 1__Development/6__Website/POPBottleServer/POPBottleServer.py @ 5:e73fbbcb5fd2
Persisting basic graph works, starting to add persist of view hierarchy too
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Sun, 03 Aug 2014 23:38:15 -0700 |
| parents | |
| children | d18eee376f45 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:165561ad5690 |
|---|---|
| 1 from bottle import route, run, template, response | |
| 2 | |
| 3 graphFile = None | |
| 4 | |
| 5 @route('/') | |
| 6 def index(): | |
| 7 return '<b>Hello</b>!' | |
| 8 | |
| 9 @route('/<name>') | |
| 10 @route('/hello/<name>') | |
| 11 def nameroute(name): | |
| 12 return template('<b>Hello {{name}}</b>!', name=name) | |
| 13 | |
| 14 @route('/savejson/<thejson>') | |
| 15 def savejson(thejson): | |
| 16 text_file = open("syntaxGraph.json", "w") | |
| 17 text_file.write("%s" % thejson) | |
| 18 text_file.close() | |
| 19 print "hello" | |
| 20 response.set_header('Access-Control-Allow-Origin', '*') | |
| 21 # return 'Got JSON!' | |
| 22 # return template('Got JSON! {{printjson}}</b>!', printjson = thejson) | |
| 23 | |
| 24 @route('/getjson') | |
| 25 def getjson(): | |
| 26 text_file = open("syntaxGraph.json", "r") | |
| 27 returnjson = text_file.read() | |
| 28 text_file.close() | |
| 29 response.set_header('Access-Control-Allow-Origin', '*') | |
| 30 return returnjson | |
| 31 | |
| 32 #=============== | |
| 33 @route('/startsavinggraph') | |
| 34 def startsavinggraph(): | |
| 35 global graphFile | |
| 36 graphFile = open("syntaxGraph.json", "w") | |
| 37 response.set_header('Access-Control-Allow-Origin', '*') | |
| 38 | |
| 39 @route('/save1elem/<thejson>') | |
| 40 def save1elem(thejson): | |
| 41 global graphFile | |
| 42 graphFile.write("%s\n" % thejson) | |
| 43 response.set_header('Access-Control-Allow-Origin', '*') | |
| 44 | |
| 45 @route('/endsavinggraph') | |
| 46 def endsavinggraph(): | |
| 47 global graphFile | |
| 48 response.set_header('Access-Control-Allow-Origin', '*') | |
| 49 graphFile.close() | |
| 50 | |
| 51 #================ | |
| 52 | |
| 53 @route('/startretrievinggraph') | |
| 54 def startretrievinggraph(): | |
| 55 global graphFile | |
| 56 graphFile = open("syntaxGraph.json", "r") | |
| 57 response.set_header('Access-Control-Allow-Origin', '*') | |
| 58 | |
| 59 @route('/get1elem') | |
| 60 def get1elem(): | |
| 61 global graphFile | |
| 62 returnjson = graphFile.readline() | |
| 63 response.set_header('Access-Control-Allow-Origin', '*') | |
| 64 return returnjson | |
| 65 | |
| 66 @route('/endretrievinggraph') | |
| 67 def endretrievinggraph(): | |
| 68 global graphFile | |
| 69 response.set_header('Access-Control-Allow-Origin', '*') | |
| 70 graphFile.close() | |
| 71 | |
| 72 run(host='localhost', port=8080) |
