This tutorial steps you through the process of creating a dynamic web application that runs on Google's servers using App Engine. The sample you'll create can be used as a template for creating new interactive web applications. This is a try-it-before-you-really-know-it tutorial-- you'll get a taste of what can be done and you'll have a lot of questions as to how it all works. In the upcoming lessons, we'll go over the sample in detail so you can understand every line of code. This tutorial uses the Linux operating system. 1. Create a folder named 'financial'. This is where all the code for your web app will go. Ideally, put this folder in a folder appEngineSamples off of your home directory. 2. Open a text editor and cut and paste the following HTML code into it. The page you are reading is at http://sites.google.com/site/usfcomputerscience/interest-rate-tutorial. <html> Save the file as 'index.html' within the folder 'financial'. The name index.html is important, so name it exactly that.<body> <h2>Interest Calculator</h2> <h3>Enter the principal and interest rate</h3> <form action="/on_calculate" method="get"> Principal:<input type="text" name="principal" value={{principal}}> Rate(%):<input type="text" name="rate" value={{rate}}> <input type="submit" value="Calculate"></div> </form> Interest Earned: {{interest}} </body> </html> 4. We'll use the Linux command-line terminal to start up a test server. The terminal is similar to the DOS prompt on Windows machines. To open a command-line terminal, choose Applications | System | Terminal from the top menu. A black window should appear. 5. In the terminal window, make sure you are in the folder above the financial folder. If financial is in your home directory, you're fine. If financial is within a folder appEngineSamples, you'll need to first change directory into appEngineSamples: cd appEngineSamples Once you're in the right directory, start the local test server by entering the following: dev_appserver financial 6. The command above starts a development app server. This server is running on your local machine, but it acts as if it is a server somewhere on the Internet. You can be access the server at a special URL. Open a Firefox browser and enter the following URL in the address bar: http://localhost:8080 This will 'run' the program you just created by accessing the server you just started. Enter a number as the principal and rate, then click 'Calculate'. The interest earned should appear. 7. If you've made it this far, your web app works, but its really not on the web yet-- your browser is just accessing a 'test' server on your local machine. Now we'll upload your application to the web, and specifically Google's App Engine servers:
8. To run your application, go to a browser and enter the name of your application, followed by 'appspot.com'. For instance, if your application identifier was 'RalphsFinancial', then enter 'RalphsFinancial.appspot.com' in your browser. If all is well, you should see a web page that looks the same as when you ran your program with the development server. Only this time, your application is really running on the web. 9. Now it's your turn to make some changes to the code and begin understanding how web programming works. Your first task is to change the program to show not just the interest earned but the updated principal after one and two years. To do this, you'll need to:
|