{"id":3528,"date":"2015-03-20T13:20:59","date_gmt":"2015-03-20T19:20:59","guid":{"rendered":"http:\/\/bililite.com\/blog\/?p=3528"},"modified":"2015-03-20T13:20:59","modified_gmt":"2015-03-20T19:20:59","slug":"running-pages-locally","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2015\/03\/20\/running-pages-locally\/","title":{"rendered":"Running pages locally"},"content":{"rendered":"<p>I want to start using <a href=\"https:\/\/pages.github.com\/\">github pages<\/a> for documentation, which would allow me to host them on github but still edit them locally and just push the edits. The problem is debugging. Anything that relies on AJAX is a security risk if I'm trying to get local files, so browsers reject any <code class=\"language-javascript\" >$.get('localfile.json')<\/code>. I understand the restriction, but it makes development very annoying. There are proposals to allow some kind of package, with <a href=\"https:\/\/code.google.com\/p\/chromium\/issues\/detail?id=47416\">only descendents of the current file<\/a>, but everyone is too scared that users will download something to their Documents folder and expose themselves.<\/p>\n<p>So the only solution seems to be to set up a local http server and use that. The simplest I've found (not very fast, but I don't need that) is to use python's http.server. First, install python (<code>choco install python<\/code> works), and then in my PowerShell profile I have a line:<\/p>\n<pre><code>function svr { Start-Process \"C:\\tools\\python\\python.exe\" \"-m http.server\" }<\/code><\/pre>\n<p>So I navigate to my desired folder, run <code>svr<\/code>, and it starts a python window running the server. <code>localhost:8000<\/code> is the URL of the folder the server is running on.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want to start using github pages for documentation, which would allow me to host them on github but still edit them locally and just push the edits. The problem is debugging. Anything that relies on AJAX is a security risk if I'm trying to get local files, so browsers reject any $.get('localfile.json'). I understand [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/3528"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=3528"}],"version-history":[{"count":2,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/3528\/revisions"}],"predecessor-version":[{"id":3530,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/3528\/revisions\/3530"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=3528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=3528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=3528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}