simplehttpserver

Is it possible to run python SimpleHTTPServer on localhost only?

a 夏天 提交于 2019-11-26 15:12:52
问题 I have a vpn connection and when I'm running python -m SimpleHTTPServer, it serves on 0.0.0.0:8000, which means it can be accessed via localhost and via my real ip. I don't want robots to scan me and interested that the server will be accessed only via localhost. Is it possible? python -m SimpleHTTPServer 127.0.0.1:8000 # doesn't work. Any other simple http server which can be executed instantly using the command line is also welcome. 回答1: If you read the source you will see that only the

Can I set a header with python's SimpleHTTPServer?

旧时模样 提交于 2019-11-26 13:47:45
问题 I'm using SimpleHTTPServer to test some webpages I'm working on. It works great, however I need to do some cross-domain requests. That requires setting a Access-Control-Allow-Origin header with the domains the page is allowed to access. Is there an easy way to set a header with SimpleHTTPServer and serve the original content? The header would be the same on each request. 回答1: This is a bit of a hack because it changes end_headers() behavior, but I think it's slightly better than copying and

What is a faster alternative to Python's http.server (or SimpleHTTPServer)?

时光总嘲笑我的痴心妄想 提交于 2019-11-25 23:23:36
问题 Python\'s http.server (or SimpleHTTPServer for Python 2) is a great way of serve the contents of the current directory from the command line: python -m http.server However, as far as web servers go, it\'s very slooooow... It behaves as though it\'s single threaded, and occasionally causes timeout errors when loading JavaScript AMD modules using RequireJS. It can take five to ten seconds to load a simple page with no images. What\'s a faster alternative that is just as convenient? 回答1: http