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