Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

http.server (SimpleHTTPServer) serve file.html instead of dir (using cmd)

Is it possible to serve not a index of a directory but rather an html file using Python SimpleHTTPServer on path '/'?

Having directory with one file login.html serves a directory index on path '/'.

python -m SimpleHTTPServer 7800

screenshot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want a content of login.html on '/'.

Is that possible?

>Solution :

SimpleHTTPServer (or http.server in Python3) will serve a directory unless that directory contains a file called index.html, in which case it will serve that instead.

So just rename login.html to index.html and it should do what you want.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading