Monday, April 14, 2014

[Python] Hosting static web pages locally on mac

Looks like I can simulate a simple FTP server locally without setting up an actual FTP or web server when development static websites. 

On your terminal, navigate to the directory of your project and start this:
$python -m SimpleHTTPServer

 And when this is printed: 
Serving HTTP on 0.0.0.0 port 8000 ...

Open localhost:8000 in browser and you should able to see your index.html rendering!

This is very handly to test out all file path of static files and simulate a FTP server locally. I can finally skip my skeleton.js node server :)

Have fun coding! 
source: http://stackoverflow.com/questions/3800143/ad-hoc-webserver-for-static-files-on-unix-macosx

No comments:

Post a Comment