Ozgen
Ozgen

Reputation: 1092

Running local HTML file with http protocol

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.

Upvotes: 8

Views: 7355

Answers (2)

Tobonaut
Tobonaut

Reputation: 2485

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

Upvotes: 8

CannonFodder
CannonFodder

Reputation: 332

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.

Upvotes: 2

Related Questions