from wsgiref.simple_server import make_server
def application(env, start_response):
response_body = ["%s: %s" % (key, value) for key, value \
in sorted(env.items())]
response_body = '\n'.join(response_body)
status = "200 ok"
response_head = [("ContextType", "text/plain"), ("ContextLength",str(len(response_body)))]
start_response(status, response_head)
return [response_body]
httpd = make_server(
"localhost",
8000,
application
)
httpd.handle_request()
An error is reported when accessing port 8000. The coding problem is modified in the
code
return [response_body]
=>Modfied
return [response_body.encode('utf-8')]
Normal operation
Read More:
- [Solved] Python Error: TypeError: write() argument must be str, not bytes
- Django WSGI protocol application, based on wsgiref module DIY a web framework
- Facenet validate_on_lfw.py Error AssertionError: The number of LFW images must be an integer multip
- [Solved] python-sutime Error: the JSON object must be str, bytes or bytearray, not ‘java.lang.String‘
- [Solved] RuntimeError: unexpected EOF, expected 73963 more bytes. The file might be corrupted.
- [Solved] Pytroch warning: “Argument interpolation should be of type InterpolationMode instead of int. “
- [Solved] Python Error: positional argument follows keyword argument
- [Solved] TVM operate error: TVMError: AssertionError
- ‘c’ argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapp
- Tensor for argument #2 ‘mat1‘ is on CPU, but expected it to be on GPU (while checking arguments for
- [Solved] Python AssertionError: MMCV==1.1.0 is used but incompatible. Please install mmcv>=1.0.5, <=1.0.5.
- [Solved] Python3.9 Pycropto RSA Error: TypeError: can’t concat str to bytes
- [Solved] AttributeError: OperationJson instance has no attribute ‘data‘
- [Solved] TypeError: Object of type ‘bytes’ is not JSON serializable
- Typeerror in Python regular expression: expected string or bytes like object
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- error: (-5:Bad argument) in function ‘seamlessClone‘ and error: (-215:Assertion failed) 0 <= roi.x && 0 [How to Solve]
- Python Error: SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3:
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- [Solved] TypeError: xx takes 1 positional argument but 4 were given