gpt4 book ai didi

python - 如何在使用 python SimpleHTTPServer 时更改默认 404 页面

转载 作者:太空狗 更新时间:2023-10-30 01:22:55 25 4
gpt4 key购买 nike

当我使用命令启动 http 服务器时:

python -m SimpleHTTPServer

如何更改默认的 404 页面?

最佳答案

用命令行,这是不可能的。

你应该制作如下脚本:

import BaseHTTPServer
import SimpleHTTPServer

class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
error_message_format = '''
custom error message
'''

BaseHTTPServer.test(MyHandler, BaseHTTPServer.HTTPServer)

关于python - 如何在使用 python SimpleHTTPServer 时更改默认 404 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18351388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com