How to Host a Static Web Site on Google Drive for Free

This is a short note on how to host a static html/css/js site for free on google's infrastructure via googledrive.  I've used this method many times within the last year.  There is some limit to how much data google will serve via this mechanism before stuttering, but it must be a big one.  One day last December, this method was used for almost 30,000 hits of a visualization that required more than 5MB of data files.  There were a few blips where it became unavailable and I put it on two other googledrive accounts, but overall seemed to do ok.


Basically, all you have to do is create a folder on googledrive with an index.html file, and then make this folder publicly viewable - this is done by setting the folder sharing to "Public on the web - Anyone on the Internet can find and view".  When you're doing this, you'll see that it says that the link is something like

https://drive.google.com/folderview?id={A BIG WEIRD STRING}&usp=sharing

To access this as a web site, you use this url:

https://googledrive.com/host/{A BIG WEIRD STRING}/

Here's what the window looks like on a Mac:
How to Share a Folder for Free Site Hosting on GoogleDrive, and
Where to Get the Main Part of the URL You'll Need
In this case, the web site will be available at
https://googledrive.com/host/0B2GQktu-wcTicEI5VUZaYnM1emM/


And that's it.  A free and easy place to host your static stuff for the world, and you can use whatever fancy javascript you want (no server-side stuff, of course).  My most recent one was this world births/deaths simulation located at

https://googledrive.com/host/0B2GQktu-wcTicEI5VUZaYnM1emM/

which has several MB of data files - it had about 3500 hits one day earlier in the month when it stayed on the front page of Hacker News for just a little bit, and then a similar modest bump a few days later when a note about it was put on the front page of one of the Canadian Broadcasting Corporation's sites. The only blip I'm aware of is a http 503 (Service Unavailable) that some people may have gotten.  This might be related to some kind of throttling that is used on the googledrive side, or an unrelated thing.  As before, I put it on two other google accounts... which themselves got little traffic, and is kind of a pain to manage, even for a casual thing like this, and I don't plan on repeating.

An Oddity with Google Drive

One odd quirk with this is that if you update a file by uploading another version of it from your desktop, then google will keep both copies of the file, which then seems to confuse the web server, and it can't serve the file.  For example, if you do this and have two copies of index.html, then a directory listing will be shown.


There might be better ways to do this with googledrive, or other similar services - let me know.





No comments:

Post a Comment

Popular Posts