python-3.x - Python http.server .path 返回 / 而不是 protocol://netloc/path#fragment
问题描述
Python 3.8 正在使用一个简单的 http 服务器,并期望 self.path 给我整个 url,因为我可以找到每个 urllib.parse 示例,将 self.path 分解成各自的部分,但是,我得到的只是'/'。
TBH 我意识到我可能搞错了,但我已经到了无处可去的阶段。
这是一个简化的服务器,我希望输出类似“http://localhost:8000#test”但我得到的只是“/”
from http.server import HTTPServer, BaseHTTPRequestHandler
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
outstr=self.path
self.wfile.write(bytes(outstr,'utf8'))
httpd = HTTPServer(('localhost', 8000), SimpleHTTPRequestHandler)
httpd.serve_forever()
有什么想法吗?
解决方案
推荐阅读
- amazon-cognito - Cognito - 当设备时区为 EDT 且当前时间设置为 IST 时,用户无法登录
- angular - 将文档引用过滤为字段
- graphql - 查询 graphiql 导致 Apollo 错误转发不是函数
- assembly - 通过CTF学习逆向
- c# - 如何在 Asp.net MVC C# 中从会话而不是数据库中插入和获取数据
- reporting-services - 如何将页脚放在矩形内
- javascript - 使用 video.js 需要 CORS
- google-apps-script - 输入后立即将 Google 表单答案写入工作表
- extentreports - 范围报告:无法为多个套件生成报告。
- machine-learning - 高成本的后果是什么?