# http://127.0.0.1:900/
from wsgiref.simple_server import make_server
def rj(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
with open(r"L:\HBuilderProjects\stu\index.html", errors="ignore") as file:
html = file.read()
return [exec("b'{}'".format(html))]
port = 900
http = make_server('', port, rj)
http.serve_forever()
运行代码,出现如下错误
Traceback (most recent call last):
File "C:\Users\yc\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "D:/Users/gyc/Desktop/服务器.py", line 6, in rj
return [exec("b'{}'".format(html))]
File "<string>", line 1
b'<!DOCTYPE html>
^
SyntaxError: EOL while scanning string literal
127.0.0.1 - - [26/Mar/2022 14:38:53] "GET / HTTP/1.1" 500