How to start python simpleHTTPServer on Windows 10

2020-06-25 04:46发布

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?

2条回答
等我变得足够好
2楼-- · 2020-06-25 04:52

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.

查看更多
Lonely孤独者°
3楼-- · 2020-06-25 04:56

If you already have python 3 installed, just run:

python -m http.server 
查看更多
登录 后发表回答