def admin_moustache(self, req: HTTPRequest, res: HTTPResponse):
        needAuth = True
        for k in ALLOWED:
            if req.path.startswith(k):
                needAuth = False
                break
        if needAuth:
            if not self.is_authorized(req, res): return

        path = os.path.abspath("www/" + req.path[7:])
        data = self.get_moustache_data()
        if req.path in MOUSTACHE_CLIENT_DATA:
            post = req.body_json()
            if not "id" in post:
                return res.bad_request(errors.ERROR_HTTP,
                                       "Le champs id n'est pas fourni (post)",
                                       None)
            if not post["id"] in self._clients._clients:
                return res.bad_request(
                    errors.ID_NOT_FOUND,
                    "L'id " + str(post["id"]) + " est incorrecte", None)
            data = self._clients._clients[post["id"]].get_moustache_data()
        res.end(html_template(path, data))
Example #2
0
def test(req, res: HTTPResponse):
    res.end("Default")