import os
import shutil
from io import StringIO
from pymongo import MongoClient, ASCENDING
from urllib.parse import urlsplit, parse_qs
from http.server import HTTPServer, BaseHTTPRequestHandler
client = MongoClient()
skindb = client.skindb
class SkinHelpRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
url = urlsplit(self.path)
qs = parse_qs(url.query)
print(url.query)
print(qs)
if url.path == "/":
self.showall()
elif url.path == "/tag":
self.showtag(qs["key"][0])
elif url.path == "/common.css":
self.staticfile("common.css")
else:
self.error_404()
def error_404(self):
rsp = "Not Found"
rsp = rsp.encode("gb2312")
self.send_response(404)
self.send_header("Content-type", "text/html; charset=gb2312")
self.send_header("Content-Length", str(len(rsp)))
self.end_headers()
se
python用http.server实现的http服务器
最新推荐文章于 2024-07-14 15:21:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)