5

I recently bought a Windows 10 machine and now I want to run a server locally for testing a webpage I am developing.

On Windows 7 it was always very simple to start a HTTP Server via python and the command prompt. Fx writing the below code would fire up a HTTP server and I could watch the website through localhost.

C:\pathToIndexfile\python -m SimpleHTTPServer

This does however not seems to work on Windows 10...

Does anyone know how to do this on Windows 10?

Kasper Christensen
  • 895
  • 3
  • 10
  • 30
  • Alternative Server Options as well: [Extremely simple web server for Windows](https://superuser.com/q/231080/180163) – KyleMit Sep 07 '18 at 00:48

3 Answers3

11

Ok, so different commands is apparently needed.

This works:

C:\pathToIndexfile\py -m http.server

As pointed out in a comment, the change to "http.server" is not because of windows, but because I changed from python 2 to python 3.

Kasper Christensen
  • 895
  • 3
  • 10
  • 30
  • 4
    Note that the change from `SimpleHTTPServer` to `http.server` is because you have switched from Python 2 to 3. It is unrelated to the Windows version. – Alasdair Mar 25 '16 at 17:13
6

If you already have python 3 installed, just run:

python -m http.server 
Ryan
  • 2,167
  • 2
  • 28
  • 33
1

On Windows, neither python nor python3 worked for me; the program just hangs there, doing nothing.

However, I got it to work via ipython:

ipython -m http.server 8000

You need to install IPython beforehand, though:

pip install ipython
daniel kullmann
  • 13,653
  • 8
  • 51
  • 67
  • after you run the command from the comment above 'python -m http.server' It starts the server. `Serving HTTP on :: port 8000 (http://[::]:8000/) ... ::1 - - [18/Nov/2020 10:34:15] "GET / HTTP/1.1" 200 - ::1 - - [18/Nov/2020 10:34:15] code 404, message File not found ::1 - - [18/Nov/2020 10:34:15] "GET /favicon.ico HTTP/1.1" 404 - ` After that, you have to open a browser and go to 'localhost:8000' – Gene R Nov 18 '20 at 15:46