8

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.

4
  • 1
    you need a web server running on your machine, e.g. Apache apachefriends.org/index.html Commented May 13, 2015 at 9:17
  • 1
    What OS are you using? If you have python, a quick solution is python -m SimpleHTTPServer 8000 Commented May 13, 2015 at 9:22
  • I need light weight solutions friends lighter than apache Commented May 13, 2015 at 9:22
  • Please see my answer. I couldn't recommend nginx enough. Very easy to configure. Commented May 13, 2015 at 9:42

2 Answers 2

8

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

Sign up to request clarification or add additional context in comments.

1 Comment

If you get No module named SimpleHTTPServer error while executing the above command you can try python -m http.server 8000
2

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.

1 Comment

Good shout, nginx also runs very well on a rasPi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.