simplehttpserver

Print statements not working when serve_forever() is called?

Print statements not working when serve_forever() is called? Question: I have the following small python script to run a local server for testing some html: print(‘opened’) from http.server import HTTPServer, SimpleHTTPRequestHandler server_address = (”, 8000) httpd = HTTPServer(server_address, SimpleHTTPRequestHandler) print("Listening at https://127.0.0.1:8000/ . . .") httpd.serve_forever() When I run this in the terminal, it blocks …

Total answers: 3

How to run a http server which serves a specific path?

How to run a http server which serves a specific path? Question: this is my Python3 project hiearchy: projet script.py web index.html From script.py, I would like to run a http server which serve the content of the web folder. Here is suggested this code to run a simple http server: import http.server import socketserver …

Total answers: 8

SimpleHTTPServer: other devices can't connect to the server

SimpleHTTPServer: other devices can't connect to the server Question: Lately I’ve been playing with Python to discover its potential and I’ve just stumbled upon SimpleHTTPServer. I’m on Windows 10. I run: python -m SimpleHTTPServer the output is: Serving HTTP on 0.0.0.0 port 8000 … I’ve opened the browser both on smartphone and tablet, but none …

Total answers: 2

Reading JSON from SimpleHTTPServer Post data

Reading JSON from SimpleHTTPServer Post data Question: I am trying to build a simple REST server with python SimpleHTTPServer. I am having problem reading data from the post message. Please let me know if I am doing it right. from SimpleHTTPServer import SimpleHTTPRequestHandler import SocketServer import simplejson class S(SimpleHTTPRequestHandler): def _set_headers(self): self.send_response(200) self.send_header(‘Content-type’, ‘text/html’) self.end_headers() …

Total answers: 2

Enable access control on simple HTTP server

Enable access control on simple HTTP server Question: I have the following shell script for a very simple HTTP server: #!/bin/sh echo “Serving at http://localhost:3000” python -m SimpleHTTPServer 3000 I was wondering how I can enable or add a CORS header like Access-Control-Allow-Origin: * to this server? Asked By: MChan || Source Answers: You’ll need …

Total answers: 6

socket.error: [Errno 48] Address already in use

socket.error: [Errno 48] Address already in use Question: I’m trying to set up a server with python from mac terminal. I navigate to folder location an use: python -m SimpleHTTPServer But this gives me error: socket.error: [Errno 48] Address already in use I had previously open a connection using the same command for a different …

Total answers: 15

Set up Python simpleHTTPserver on Windows

Set up Python simpleHTTPserver on Windows Question: I want to set up Python SimpleHTTPServer on Windows XP. I have Python installed on my computer. I am executing the following command: python -m SimpleHTTPServer 8888 But I am getting the error: C:Python33python.exe: No module named SimpleHTTPServer Is SimpleHTTPServer for Python available on Windows? If yes, what …

Total answers: 1

How do I shut down a python simpleHTTPserver?

How do I shut down a python simpleHTTPserver? Question: So I’m trying to learn d3, and the wiki suggested that To view the examples locally, you must have a local web server. Any web server will work; for example you can run Python’s built-in server: python -m SimpleHTTPServer 8888 & Great… only now I have …

Total answers: 9

Can I set a header with python's SimpleHTTPServer?

Can I set a header with python's SimpleHTTPServer? Question: 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 …

Total answers: 4

Is it possible to run python SimpleHTTPServer on localhost only?

Is it possible to run python SimpleHTTPServer on localhost only? Question: 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 …

Total answers: 3