Today
we will enjoy creating a simple web application, actually a guessing game, and will try to set it up on Facebook ;) BUT
First, we need to take a deep look on Google
App Engine platform and then go for some installation instructions. App Engine
is a complete development stack that uses familiar technologies to build and
host web applications. With App Engine all you need to do is to write your
application code, test it on your local machine and upload it to Google with a
simple click of a button. Once your application is uploaded to Google, it is
automatically hosted and scaled for you. So no need to worry about system
administration, bringing up new instances of your application, sharing your
database or buying machines (even no need to configure Web servers on your
machine to test your application locally!!). Google will take care of all the
maintenance so you can focus on coding only.
Google App Engine costs nothing to get started,
Once you have gmail account, sign up for the GAE service then create account
and publish an application that people can use right away at no charge from
Google. But as you go for using more resources, you will have to pay for that. All applications can use up to 1 GB of storage and enough CPU and bandwidth to support an efficient app serving around 5 million page views a month, absolutely free. But as you go for using more resources, you will have to pay for that and you only pay for resources you use above the free levels.
Google App Engine offers some advantages to
developers:
·
Automatic scaling: is
built in with App Engine, No matter how many users you have or how much data
your application stores, App Engine can scale to meet your needs.
·
High performance and reliability: with App Engine you can take advantage of the 10 years of knowledge
Google has in running massively scalable, performance driven systems.
·
Security: all Google
applications' privacy and data protection policies are applied to all App
Engine applications. GAE protects your code and application data.
Technical Details about GAE:
With Google App Engine you can:
- Serve your app from your own domain name (such as http://example.com/) using Google Apps
- Or serve your app using a free name on the appspot.com domain.
- Share your application with the world, or limit access to members of your organization.
- write apps in several programming languages. With App engine's Java runtime environment, you can build your app using standard java technologies like JSP, Java Servlets, JavaScript, Ruby, Python, and Go languages.
The article is going to be little long but more interesting ;)
1. First, you should have already installed JDK 6 and downloaded Eclipse 3.7 (Indigo).
2. Install the Google Plugin for Eclipse using the Software Update feature of Eclipse:
a. Select Help menu > Install New Software
b. In the "Work with" text box, enter the URL shown in the figure below:
Using Google Plugin for Eclipse:
If you use the Eclipse development environment (which is highly recommended), you can use the Google Plugin for Eclipse to create, test, and upload your App Engine Web Applications. To do so, follow the steps bellow:1. First, you should have already installed JDK 6 and downloaded Eclipse 3.7 (Indigo).
2. Install the Google Plugin for Eclipse using the Software Update feature of Eclipse:
a. Select Help menu > Install New Software
b. In the "Work with" text box, enter the URL shown in the figure below:
3. Click the plus icon next to "Google Plugin for Eclipse" and "SDKs". Check the boxes next to "Google Plugin for Eclipse 3.7" and "Google App Engine Java SDK". You can also select the "Google Web Toolkit SDK" if you'd like to use Google Web Toolkit with your apps. Click the Next button. Follow the prompts to accept the terms of service and install the plugin.
4. When the installation is complete, Eclipse prompts you to restart. Click Yes. Eclipse restarts and then voila`! plugin is installed ;).
Create a Web Application using Google App Engine SDK:
Here we go:
1. Click the New Web Application Project button in the toolbar:
2. Then Create a new web application:
3. Click Finish Button and then here is the project created:
4. Double-click the file "index.html" and put the following code inside the <body> </body> tag:
<h1>Hello App Engine!</h1>
<script type=text/javascript>
var iRandom;
function Restart()
{
iRandom = Math.floor(Math.random()*10)+1;
alert('OK, I am thinking of a number between 1 and 10');
}
function Guess()
{
var yourGuess = document.getElementById('myGuess').value;
if (yourGuess>iRandom)
alert('Too High.');
if (yourGuess<iRandom)
alert('Too Low.');
if (yourGuess==iRandom)
{
alert('Well done! You guessed it.');
Restart();
}
}
</script>
Enter your guess between 1 and 10: <input type=text id='myGuess' name='myGuess'>
<input type='button' onClick='Guess()' value='Guess'>
<br>
<br>
<input type='button' onClick='Restart()' value='Start Again'>
<script type=text/javascript>
Restart();
</script>
Now, it is time to run and deploy the application. There are two ways to deploy your application:
1. Locally: right-click on your project > Run As > Web Application
Here is your Application is running locally!
2. Publicly: using the free domain appspot.com by uploading your application files on Google App Engine's web host. This requires you to create an account with Google App Engine. Let's see how?
a. Go to this link: https://appengine.google.com/
b. Then create an account for your Web application:
c. Then enter your mobile number so Google will send you the verification code to your mobile:
d. You will have to enter this verification code in the next step and then you will be asked to create an application by entering Application ID and title:
e. Next, click Google menu button and choose "Deploy to App Engine":
f. Sign in with your gmail account:
g. Continue authenticating:
** Important Note:
Before deploying your web application, go to your project in Eclipse and find an XML file with name "appengine-web.xml" and set your application id as registered on appspot.com domain which is "raniagame" in this example, see the figure below:
h. Then choose your project and click button "Deploy":

i. Then your project will be uploaded to the application you already registered with the app engine:
j. Finally your application is deployed successfully:
k. Now, let's go to the Web browser and write this URL:
http://raniagame.appspot.com/
Now, how about setting this application on facebook? ;)
1. To do so, go to http://developers.facebook.com/apps and click button "Create New App"
2. Then put the name of the facebook app
3. Fill the following fields as shown below and click button "Save Changes":
4. Verifying these entries might take minutes so don't panic if it didn't work quickly, afterwards, you will find the app working fine and here is the result:
So start socializing and get feedback from your friends about your application whatever it is ;) that's all for this article, I hope it was useful and wish you good luck all ;) :)
















