def request_url(task): url = task.url if url is None: url = "" quoted_url = xutils.quote_unicode(url) if quoted_url.startswith(("http://", "https://")): # 处理外部HTTP请求 response = xutils.urlopen(quoted_url).read() xutils.log("Request %r success" % quoted_url) return response elif url.startswith("script://"): name = url[len("script://"):] return xutils.exec_script(name, False) cookie = xauth.get_user_cookie("admin") url = url + "?content=" + xutils.quote_unicode(str(task.message)) return self.app.request(url, headers=dict(COOKIE=cookie))
def save(): xmanager.request("/file/add", method="POST", data=dict(name=name, content=text, type="md"), headers=dict(COOKIE=xauth.get_user_cookie(user_name)))