Running local HTML file with http protocol

I have a html file, when I click it, the browser window pops up with file:///c:/myhtml.html

. How can I run this file using http protocol scheme so the url is like http://localhost/myhtml

?

I don't want to set up a super heavy web server. Is there a nice and neat solution for this?

Why I want to do this, check my html file according to the http protocol instead of the protocol file:///

that browsers restrict some functionality on.

+3


source to share


2 answers


If you have Python installed , type ...

python -m SimpleHTTPServer 8000

...

If you have Ruby installed , type ...

ruby -run -e httpd . -p 8000



... in your cmd.exe or Terminal.app

This will start a very simple http server that will serve your current folder as an http context.

Result URL

http: // localhost: 8000

+3


source


I suggest you take a look at nginx . It's pretty lightweight and easy to set up. It is well documented as well (see the static content serving section for what you requested).



There are many tutorials on the Internet that show you how to get started. You can build a simple web server effortlessly.

+2


source







All Articles