Esempio n. 1
0
    def do_GET(self):

        print('get', self.path)

        page = dispatchUrl(self.server.proj, self.path)
        if page:

            self.ok_html()
            self.wfile.write(
                "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\" /></head><body>"
            )

            if page.has_name_form:
                self.wfile.write(
                    name_form(page.addr, self.server.proj.database))

            renderer = HtmlRenderer(self.server.proj.database)

            page.load()
            page.render(renderer)

            self.wfile.write(renderer.getContents())

            self.wfile.write("</body></html>")

        elif self.path == '/style.css':
            self.send_response(200)
            self.send_header('Content-type', 'text/css')
            self.end_headers()
            with open('style.css', 'r') as f:
                self.wfile.write(f.read())

        elif self.path == '/favicon.ico':
            self.send_response(200)
            self.send_header('Content-type', 'image/x-icon')
            self.end_headers()
            with open('favicon.ico', 'r') as f:
                self.wfile.write(f.read())

        elif self.path.startswith('/set-name?'):
            q = urlparse(self.path).query
            p = parse_qs(q)
            print(p, q)
            addr = address.fromConventional(p['addr'][0])
            name = p['name'][0]
            self.server.proj.database.setNameForAddress(addr, name)
            self.redirect(self.headers['Referer'])

        elif self.path == '/quit/':
            self.server.request_stop = True
            self.send_response(200)
            self.end_headers()

        else:
            self.send_response(404)
            self.end_headers()
Esempio n. 2
0
    def do_GET(self):

        print('get', self.path)


        page = dispatchUrl(self.server.proj, self.path)
        if page:

            self.ok_html()
            self.wfile.write("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\" /></head><body>")

            if page.has_name_form:
                self.wfile.write(name_form(page.addr, self.server.proj.database))

            renderer = HtmlRenderer(self.server.proj.database)

            page.load()
            page.render(renderer)

            self.wfile.write(renderer.getContents())

            self.wfile.write("</body></html>")

        elif self.path == '/style.css':
            self.send_response(200)
            self.send_header('Content-type', 'text/css')
            self.end_headers()
            with open('style.css', 'r') as f:
                self.wfile.write(f.read())

        elif self.path == '/favicon.ico':
            self.send_response(200)
            self.send_header('Content-type', 'image/x-icon')
            self.end_headers()
            with open('favicon.ico', 'r') as f:
                self.wfile.write(f.read())

        elif self.path.startswith('/set-name?'):
            q = urlparse(self.path).query
            p = parse_qs(q)
            print(p, q)
            addr = address.fromConventional(p['addr'][0])
            name = p['name'][0]
            self.server.proj.database.setNameForAddress(addr, name)
            self.redirect(self.headers['Referer'])

        elif self.path == '/quit/':
            self.server.request_stop = True
            self.send_response(200)
            self.end_headers()

        else:
            self.send_response(404)
            self.end_headers()
Esempio n. 3
0
    def openPage(self, url):
        self.text.delete(1.0, 'end')

        if not self.proj:
            self.text.insert('end', 'Project is not open')
            return

        page = dispatchUrl(self.proj, url)
        if not page:
            self.text.insert('end', '404 Not found')
        else:
            renderer = TkRenderer(self.proj.database, self.text)
            page.load()
            page.render(renderer)
Esempio n. 4
0
    def openPage(self, url):
        self.text.delete(1.0, 'end')

        if not self.proj:
            self.text.insert('end', 'Project is not open')
            return

        self.url = url
        page = dispatchUrl(self.proj, url)
        if not page:
            self.text.insert('end', '404 Not found')
        else:
            renderer = TkRenderer(self.proj.database, self.text)
            if page.has_name_form:
                self.address_name.setAddress(page.addr)
            page.load()
            page.render(renderer)