{
"$type": "site.standard.document",
"description": "This weekend I was playing with Facebook’s JavaScript SDK and I needed a quick way to serve over HTTP the files I was working on, so that I could access them in a browser window at http://localhost. I...",
"path": "/blog/http-server",
"publishedAt": "2011-12-13T13:55:47.000Z",
"site": "at://did:plc:k4tdr3iybw7ntu4c4dg64af7/site.standard.publication/3mn5s3qvnj22t",
"tags": [
"HTTP",
"Python"
],
"textContent": "This weekend I was playing with Facebook’s JavaScript SDK and I needed a quick way to serve over HTTP the files I was working on, so that I could access them in a browser window at http://localhost.\nI didn’t want to go through the hassle of setting up Apache on my Mac, though, and I was looking for some quick alternative to installing a local web server. After some Googling, I found a wonderful one liner that did the job, provided that you have Python installed.\nOpen a Terminal window and go to the directory containing the files you want to serve and run:\npython -m SimpleHTTPServer\nor, if you are using Python 3,\npython -m http.server\nyou will then be able to access your files on http://localhost:8000/. (You can specify a different port number by passing the number as last argument, just remember that you need root permissions to open sockets on ports lower than 1024.)",
"title": "Tip: serve local files over HTTP with one console command"
}