Jump to content

Develop without local web server


wasser
 Share

Recommended Posts

Although launching a local web server with Python is pretty easy (python -m SimpleHTTPServer <port>), I often choose to just run a temporary instance of Chrome with the --allow-file-access-from-files flag. This should bypass Chrome's check for preventing local assets from loading due to same-origin policy. Here's how you'd do it on various systems:

 

OSX

open -a Google\ Chrome --args --allow-file-access-from-files

Windows

1) create a shortcut of Chrome

2) right-click on the shortcut

3) go to "Properties" and "Shortcut"

4) Edit the Target field to read something like: 

"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --allow-file-access-from-files

Linux

google-chrome  --allow-file-access-from-files

If Chromium is your cup of tea, it will work there as well, just replace references to Chrome(.exe) with the appropriate Chromium executable.

 

You could also use the "--disable-web-security" flag instead, but it's a little more far-reaching, I believe, and browsing other sites with that flag enabled is probably not a great idea :)

 

Tip: Make sure all running instances of Chrome (also check task manager for running processes) are killed before starting a new instance of Chrome like this. 

 

Hope this is useful for someone.

 

Thanks,
wasser

Link to comment
Share on other sites

Nice trick, but I'm not sure if you're not overdoing it. First, you have to close your Chrome session before starting it again with the parameters, then remember to close it again after doing your stuff. You also loose the ability to use domain- and protocol-relative URLs. Because of that, starting a simple server seems much faster, doesn't it?

Link to comment
Share on other sites

I imagine that such method would work if Chrome isn't your primary browser (thus can be kept just for running that single instance of game). Launching a Python or Neko webserver is easy enough of process by itself though - if you feel that lazy, under Windows you can also add a single registry key to grant you a "Launch web server here" item for folder' context menu.

Link to comment
Share on other sites

I imagine that such method would work if Chrome isn't your primary browser (thus can be kept just for running that single instance of game). Launching a Python or Neko webserver is easy enough of process by itself though - if you feel that lazy, under Windows you can also add a single registry key to grant you a "Launch web server here" item for folder' context menu.

 

i am that lazy, how do you do that ?

 

The latest Flashdevelop has a webserver for testing Html5, haven't tested it though, just installed.

Link to comment
Share on other sites

Just a couple of little points...

 

What wasser wrote is right but keep in mind your path to Chrome is likely to be different...typically Chrome is only installed in the programs folder if you install it through some pack or something, but right clicking on the shortcut will tell you.  Also, there is no need for the "--args".

 

What qudodup wrote is also right.  Having a profile just for development is a good idea as you can remove any extensions that might interfere with your work.  If you want a new profile, but want it to start off where your current profile is at then you can copy your current profiles folder somewhere else and rename it to whatever.  All your current profiles are kept in a directory called User Data that you will find in Chromes directory, copy that whole directory to somewhere and point the --user-data-dir to it.

 

If you ever want to know what the Chrome command line arguments are then go here....

http://peter.sh/experiments/chromium-command-line-switches/

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...