Saturday, March 29, 2014

Deploying a developmental website

Hey guys! I know I'm posting after a long time. Between semester projects and some of my own I almost forgot about the blog. My bad.
So in this article we'll see how to host your site on a free server. There are three advantages of doing this:

  1. Whoever you're working with can see the progress in real time, no matter where they're physically located.
  2. You would be editing the code on the server host website instead of your machine, which gives you the freedom to work on it from anywhere with an Internet connection.
  3. You need to add libraries to Django to, say, send emails, serve static files like images ('img src' doesn't work straightaway in Django) etc. The server host website will come preloaded with all these, and will constantly update itself, so you won't have to worry about it.
So let's get started. I host it on pythonanywhere.com, where it is mundanely easy. Sign up on it. There's a normal signup procedure, verification email etc. Once you're done, log in. Now you'll see several tabs: Consoles, Files, Web, Schedules, and Databases. Go to the 'Consoles' tab.
Over there, click on Bash console. In it, do the normal startproject and startapp procedure explained earlier in this tutorial.
Once done, go to the 'Files' tab and you'll see all your project files. Now copy code from whatever files you have on your machine to the respective files on the server. Alternatively, you can go to the 'Files' tab and directly upload your entire project.
Then go the 'Web' tab and click on 'Reload username.pythonanywhere.com' and your site is live!
Go back to the 'Files' tab. When you click on a particular file, the contents will be displayed in the code editor. Make your changes. Note that whenever you make any changes you have to reload the site. There's a button at the top of the code editor or you can go to the 'Web' tab as earlier.
That's all for now!
Cheers!