Exemplo n.º 1
0
 def serve_bootstrap_map(self):
     # TODO: should we actually do this ...?
     try:
         root = os.path.realpath(os.path.join(paths.rootdir, ".."))
         fn = os.path.join(
             root, 'node_modules/bootstrap/dist/css/bootstrap.min.css.map')
         mimetype, encoding = mimetypes.guess_type(fn)
         with open(fn, 'rb') as fp:
             data = fp.read()
         return server.HttpResponse(data, mimetype)
     except Exception:
         raise server.InvalidResource(self.route)
Exemplo n.º 2
0
    def serve_main(self):
        if self.route != '/':
            raise server.InvalidResource(self.route)
        return server.HttpResponse(r"""
<html>
  <head>
    <link rel="icon" href="static/dist/favicon.ico" type="image/x-icon">
  </head>
  <body id="body">
    <script src="static/dist/nengo.js" type="text/javascript" charset="utf-8"></script>
  </body>
</html>
      """.strip().encode("utf-8"))
Exemplo n.º 3
0
    def http_GET(self):
        if self.server.settings.prefix is None:
            if self.server.verify_token(RequireAuthentication.get_token(self)):
                prefix = self.resource
                if prefix.endswith('/'):
                    prefix = prefix[:-1]
                self.server.settings.prefix = prefix
                RequireAuthentication.authenticate(self)
            else:
                raise server.InternalServerError("Prefix not set.")

        if not self.resource.startswith(self.server.settings.prefix):
            raise server.InvalidResource(self.resource)
        self.resource = self.resource[len(self.server.settings.prefix):]
        server.HttpWsRequestHandler.http_GET(self)
Exemplo n.º 4
0
    def serve_main(self):
        if self.resource != '/':
            raise server.InvalidResource(self.resource)

        filename = self.query.get('filename', [None])[0]
        reset_cfg = self.query.get('reset', [False])[0]
        page = self.server.create_page(filename, reset_cfg=reset_cfg)

        # read the template for the main page
        html = pkgutil.get_data('nengo_gui', 'templates/page.html')
        if isinstance(html, bytes):
            html = html.decode("utf-8")

        # fill in the javascript needed and return the complete page
        components = page.create_javascript()
        data = (html % dict(components=components)).encode('utf-8')
        return server.HttpResponse(data)