Feeds:
Posts
Comments

Posts Tagged ‘Google App Engine’

Exciting news for all Java developers today, as Google App Engine (GAE) now officially supports Java as a programming language.

The App Engine is able to run Java web applications using the Java 6 virtual machine (JVM). App Engine uses the Java Servlet standard for web applications (JSP files, static files, servlets, web.xml etc.) in the usual WAR file structure.

Download the GAE SDK for Java / Google Plugin for Eclipse
Read about the Google Plugin for Eclipse
Read the App Engine Java Overview
Official Announcement at the GAE Blog

Read Full Post »

I have always been fascinated with the Google App Engine (GAE) concept.
In the past I have posted a couple of “Getting Started” technical articles about GAE, however I never had the chance to spent more time with it.

Last week I came up with an idea about a possible Web application. And I thought that it would be cool to implement it on GAE’s infrastructure.
It was also exciting that I would have to use Python for the first time on a real project. Most of my previous Web applications were developed on PHP or ASP.NET platforms.

Anyway, the web application I’m talking about is RapidLinkr, which is now up and running on GAE!

I just hope that Google App Engine’s free quota will be more than enough.

Here is what RapidLinkr is all about:

The user inputs a list of links in plain text form, via copy/paste or by typing them.
The application is parsing those links, and outputs them as HTML hyperlinks. Now the user can rapidly open all these links in new tabs/windows via a single click! Or else click on any of the formed hyperlinks to open them.

It has to be mentioned that all links entered are in no way permanently stored or recorded.

Thus, if you are tired, or simply don’t have enough time to spent on opening lots of links manually, RapidLinkr might be the right tool for you!

Enjoy the service, feedback and comments are always welcome.

RapidLinkr – Main
RapidLinkr – Help
RapidLinkr – Disclaimer

Read Full Post »

This is my second article about the Google App Engine.
On the previous article, I have gone through the installation/setup process, and a “Hello World” project.

Introduction

While developing web applications it is always a good practice to separate the presentation layer from the application logic. This approach is recommended for all modern web frameworks, whether that is PHP, ASP.NET, Google App Engine etc.

During the design time, different people/teams may work on each layer, i.e. web designers on the presentation layer, and programmers on the code-behind. Maintenance will also be easier, as it could only involve the update of a single layer.

In our case, the presentation layer is going to be a simple HTML file, and the application logic a Python script file.

Coding – Part 1

Create a new folder on your hard disk called “template”.

Create the “template.py” file with the following code:

import wsgiref.handlers, os

from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

class MainPage(webapp.RequestHandler):
    def get(self):
        html_title = 'Google App Engine - Template'
        html_body_text = 'This is a simple demo of the templating system.'

        template_values = {
            'html_title': html_title,
            'html_body_text': html_body_text,
            }

        path = os.path.join(os.path.dirname(__file__), 'index.html' )
        self.response.out.write(template.render(path, template_values))

def main():
    application = webapp.WSGIApplication(
                                    [('/', MainPage)],
                                    debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()

On the above code we are declaring two variables, named html_title and html_body_text.
The html_title will form the HTML title content, while the html_body_text is going to be printed on the HTML body.

Now, let’s include the variables on the HTML file, named “index.html”:

<html>
<head>
    <title>{{ html_title }}</title>
</head>
<body>
    
{{ html_body_text }}
</body>
</html>

We also need to create the configuration app.yaml file with the following code:

application: template
version: 1
runtime: python
api_version: 1

handlers:
- url: /
  script: template.py

Now let’s start the development web server by typing in the command prompt:
“dev_appserver.py D:\GoogleAppEngine\template”
Please replace the “D:\GoogleAppEngine\template” with the path of your “template” folder.

Point your web browser to http://localhost:8080/ , and you should see something like the following output:

Coding – Part 2

Now we are going to further improve our presentation layer by adding a CSS file.

Create a subfolder named “stylesheets” inside the “template” folder.

Create the “template.css” stylesheet file with the following code:

p {
    color: #FF0000;
}

Edit the “index.html” in order to include the CSS file:


<html>
<head>
	<title>{{ html_title }}</title>
	<link type="text/css" rel="stylesheet" href="/stylesheets/template.css" />
</head>
<body>
	
{{ html_body_text }}
</body>
</html>

Add the following handler on the app.yaml file:

- url: /stylesheets
  static_dir: stylesheets

Save all files, refresh your browser, and you should see the following output:

Conclusion

Google App Engine template system is based on Django’s template engine, and as demonstrated above, it is quite easy to be implemented.
You can find a more complicated example on Google App Engine’s template help page, using class properties and if/else logic on the presentation layer.

Read Full Post »

Introduction

Lately I have been reading quite a lot of articles about Google App Engine, and I just couldn’t resist trying it out myself.

Google App Engine enables you to build web applications on the same scalable systems that power Google applications.

If this is the first time you are hearing about the Google App Engine, it would be a good idea to read this introductory document.

The following post is based on the official “Getting Started” guide.

Setup

Setup is quite easy, all you need is the Google App Engine SDK, and the Python Runtime software.
I am using Windows XP, so I have downloaded the “GoogleAppEngine_1.0.1.msi” and “python-2.5.2.msi” installers from the above links.
Both of them are available for Windows/Mac/Linux, so you can download the required files according to your Operating System.
Installation is also straight-forward, I have installed both of them with the default options. There was no need to edit config files or do something else.
Google App Engine even sets a “Path” Environment Variable in Windows to make the development web server more accessible.

Coding – Part 1

Here comes the fun part, let’s find out how to build the “Hello World” application.

Create a new folder on your hard disk called “helloworld”.

Fire up your favorite text editor, mine is Notepad++, and paste the following code:

print 'Content-Type: text/plain'
print ''
print 'Hello World!'

Save the file as “helloworld.py” inside the folder “helloworld”.

Create a new text file called “app.yaml” in the same folder with the following contents:

application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py

The “app.yaml” is the configuration file, you can find more information about it here.

Now let’s start the development web server by typing in the command prompt:
“dev_appserver.py D:\GoogleAppEngine\helloworld”
Please replace the “D:\GoogleAppEngine\helloworld” with the path of your “helloworld” folder.

Point your web browser to http://localhost:8080/ , and you should see something like the following output:

Now change the “helloworld.py” a bit:

print 'Content-Type: text/plain'
print ''
print 'Hello World! - Google App Engine rocks!'

Save it, refresh your browser, and you should see:

The development web server is monitoring the project files, thus you can automatically view the changes!

Coding – Part 2

On this second part we are going to use the included, with the SDK, “webapp” framework.

Let’s create a new Python script file called “helloworld2.py” with the following contents:

import wsgiref.handlers

from google.appengine.ext import webapp

class MainPage(webapp.RequestHandler):
  def get(self):
    self.response.headers['Content-Type'] = 'text/plain'
    self.response.out.write('Hello World from the webapp framework!' )

def main():
  application = webapp.WSGIApplication(
                                       [('/helloworld2', MainPage)],
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
  main()

We also need to modify the configuration file (app.yaml), in order to specify the url that is going to handle the second script:

application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /
  script: helloworld.py

- url: /helloworld2
  script: helloworld2.py

As you can see, we changed the first handler (/.* -> /) to respond only to the root directory.
Also we added a second handler to respond on the /helloworld2 path.

Navigate your browser to http://localhost:8080/helloworld2 and you should see:

You can find here more information about the “webapp” framework and how to use it.

Conclusion

Well that was just the beginning to an exciting new way of developing web applications.
The API is under heavy development, and definitely you have to spend some time in order to get familiar with it, and build a real-world application.

Read Full Post »