Serve a Directory

posted by Jake on

Don't you hate developing a blasted simple webpage that does some asynchronous requests that gets you into cross-origin policy trouble. If you just read a `.html` file off the file system, this will bite you. But, it's easy to get around. Just host your .html file on a simple http server. And it's easy to make that happen. Here's one way.

Attacked by Snakes

First, Verify you have python installed:

> python --version
Python 2.7.3

'Tis a Gift to Be Simple

Then navigate to the directory that you'd like to serve up and type:

python -m SimpleHTTPServer 5000

Where "5000" is the port you'd like to serve it on. (Defaults to 80.) Then point your browser to:

http://localhost:5000

And rock your local dev.

Share the delectableness

About Jake Trent

Jake wrestles mean codes during the day, comes home to his beautiful wife, superstar son and delightful daughter in the evenings, and enjoys every day of it. RockyCode is one of his brain children, a prize of battle, won after a legendary struggle with his innermost thoughts and unwieldy hex digits. More by Jake

Leave a comment

blog comments powered by Disqus