Requirements: Some third-party tools are python scripts, I do C# development myself, I am not proficient in python itself, if you translate python code into C# code, it is very difficult, it is better to use python to open an http service, I call interface two, and finally execute python itself to execute its internal code.
HTTPServer is a subclass of socketserver.TCPServer. It creates and listens for HTTP sockets to dispatch requests to handlers.
Documentation:The hyperlink login is visible.
Tip: http.serverNot recommended for production。 It only implements basic security checks.
The code is as follows:
Use Python to listen for port 10254, enable the HTTP service, and try to access the URL, as shown in the following figure:
The tests are accessible, however, when I use the edge browser to access multiple times, sometimes alwayspendingstate, after I establish a connection from the native through telnet and port 10254, I found that the http service is not accessible from both the server and the local, as shown in the picture below,No response for 20 minutes, and in the end, I could only re-request:
At first, I thought it was a problem that there was no "Content-Length" setting, causing the browser to not know how many bytes of content to read, and I didn't know when the reading was completed, but after the response header, the problem was still not solved.
Could it be that the default is single-threaded, allowing only one client to access at a time?
Looking at the documentation, I found that there is a ThreadingHTTPServer class, which uses threads to process requests by using threads, and the code is changed to the following:
Problem solved, finished.
|