setting up a local server could be time taking and there’s a heck lot of ways to do it, but when it comes to make a simple ajax query call or making image calls in the HTML5 canvas; it will need a localhost server!
i’m sure you must be thinking “ah that’s not a problem allow me install 100+ mb softwares like mamp, wamp” or some might even start writing “npm install gulp –save” on the command line, hold on a minute!! the following is possibly the quickest/coolest way to do it without even installing anything! 🙂
JUST USE THE FOLLOWING SNIPPET!!!
python -m SimpleHTTPServer 3000
Scanning the snippet :
- The above code opens up the current directory in a localhost server
- open up the directory where you’re index.html file is in a command line, and copy the above command!
- open up a browser, go to localhost:3000
- your index.html page would be up for making ajax calls 🙂
it goes without saying that the prebuilt python is one to rescue this problem, (perhaps not the very first time), also this may not be a good option if you’re doing something serious. (yes, npm is still the king)
PS: Python is prebuilt in Mac and some linux distribution!
PSS: if you’re on windows the better option would be to run gulp! 😉
here’s a link to give a brief about why they don’t have it prebuilt with windows