I have a html file, when I click it, browser window pops up with file:///c:/myhtml.html
. How can I run this file with http protocol scheme, so that the url would be like http://localhost/myhtml
?
I don't want to setup a heavyweight webserver. Is there any nice and neat solution for this?
Why I want to do this is, to test my html file under http protocol instead of file:///
protocol on which browsers restrict some functionality.
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 launch a very simple http-server that serves your current folder as a http-context.
Resulting URL
http://localhost:8000
I'd suggest you look at nginx. It's pretty lightweight and easy to configure. It's also well documented (look at the serving static content section for what you've requested).
There are a lot of tutorials online showing how to get started. You can create a simple web server without much effort.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With