Monday, July 8, 2013

Using Google Drive As A Web Host

  1. Go to Google Drive Of course, you gotta have a Google account to begin in the first place and then just type in drive.google.com
  2. Create a public folder This is important. If you want to use Google Drive as a web host, you need to keep your files in a public directory. Create a new folder and then simply choose the 'share' button and give it public access. Lets assume my folder is called 'ryan'
  3. Dumping your static files Lets say that your site has a lot of html pages, css stylesheets, jQuery, javascript, images - the usual stuff. Just add all your files in the same directory structure in which they are present in your local system to the public folder that you just created. So, all my files are dumped into the public folder called 'ryan' in my google drive.
  4. Naming convention Ensure that at least one file in the public folder is named as index.html. This will act as the landing page for your site.
  5. What to publish Now comes an important step. In order to share your site, you need to share a link to the public folder. Initially I thought that you would need to share the link to the index.html but that did not work as expected. So what you need to do is,  note the google drive file-id of your public folder. To do that, just open your public folder in google drive. By default it lists all the files in that folder. In the url at the top, you will see that it contains a long string of garbled aphanumeric characters after the last slash. That is your folder id. Copy it.
  6. Creating a url to publish Now all you need is a url that points to your folder. To create your url, simply append the file id to the following string - http://googledrive.com/host/ For eg. The raw link to my profile on google drive is http://gdriv.es/chetan

And that pretty much does it. Clicking on the above URL serves the index.html page of your public folder.  Other Tips 
  1. If you want to use a neat little name instead of the long string of garbled alphanumeric characters that appear at the end of the url, go to Gdriv.es and convert your folder id custom name. That's what I did for my profile, and now it looks like this - http://gdriv.es/chetan. Much more neat i'd say.
  2. Sometimes its just easier to download Google Drive for the desktop, edit your files right in your local machine and then watch them automatically get uploaded.
  3. When multiple pages are interlinked, I have observed that the url in the address bar remains the same. So, I guess bookmarking will be an issue in this case.

No comments:

Post a Comment

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...