def create_DebugHandler(controller):
    with open(localdir("html/debug.html"), "r") as f:
        content = str(f.read())
        templ = tornado.template.Template(content)
    
    queries = OrderedDict()
    cur_text = ""
    with open(localdir("../docs/JSON_examples.txt"), "r") as ef:
        for l in ef.readlines():
            if len(l) <= 1:
                continue
            elif l[0] == "#":
                continue
            elif l[0] == "{":
                queries[cur_text] = l[:-1]
                cur_text = ""
            else:
                cur_text += l[:-1]

    
    class DebugHandler(tornado.web.RequestHandler):
        def get(self, *args):
            self.write(templ.generate(q=queries))
            
        def post(self, *args):
            self.write(templ.generate(q=queries))
    
    return DebugHandler
Exemple #2
0
 def get(self, *args):
     if controller.ow.debug:
         f = open(localdir("html/index.html"), "r")
         _content = str(f.read())
         self.write(_content)
     else:
         self.write(content)
Exemple #3
0
 def get(self, *args):
     if controller.ow.debug:
         f = open(localdir("html/index.html"), "r")
         _content = str(f.read())
         self.write(_content)
     else:
         self.write(content)
Exemple #4
0
def create_MainHandler(controller):
    # TODO cache html/index.html
    if not controller.ow.debug:
        f = open(localdir("html/index.html"), "r")
        content = str(f.read())
    
    class MainHandler(tornado.web.RequestHandler):
        def get(self, *args):
            if controller.ow.debug:
                f = open(localdir("html/index.html"), "r")
                _content = str(f.read())
                self.write(_content)
            else:
                self.write(content)
            
        post = get
    
    return MainHandler
Exemple #5
0
def create_MainHandler(controller):
    # TODO cache html/index.html
    if not controller.ow.debug:
        f = open(localdir("html/index.html"), "r")
        content = str(f.read())

    class MainHandler(tornado.web.RequestHandler):
        def get(self, *args):
            if controller.ow.debug:
                f = open(localdir("html/index.html"), "r")
                _content = str(f.read())
                self.write(_content)
            else:
                self.write(content)

        post = get

    return MainHandler