Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 441
Ozgen Avatar asked May 13 '15 09:05

Ozgen


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 launch a very simple http-server that serves your current folder as a http-context.

Resulting URL

http://localhost:8000

like image 142
Tobonaut Avatar answered Nov 01 '22 06:11

Tobonaut


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.

like image 2
CannonFodder Avatar answered Nov 01 '22 06:11

CannonFodder