[Google App Engine] Hello, world!

Source: Internet
Author: User

1. register an application on Google App EngineProgram. After the application is registered, it will assign you a domain name. For example, xxx.appspot.com is assigned to the xxx application.

2. Python used for Google App Engine development. If you want to debug it locally, You need to configure the local environment. You can use the server provided by the SDK provided by Google, of course, you can also use IIS to run it! Let's take a look at how to configure python in iis7. Note that the Google server uses python2.5. Although Python has reached 3.0, we recommend that you install version 2.5.2 to facilitate uniformity.

3. Now we can create home. py on our first page. The content is very simple, that is, print some strings:

Print   ' Status: 200 OK '
Print   ' Content-Type: text/html '
Print   ''
Print   ' <HTML> '
Print   ' <Body> '
Print   ' <H1> Hello, world! This is my home! </H1> '
Print   ' </Body> '
Print   ' </Html> '

 

4. Now that we have a page, how can we publish it to xxx.appspot.com?

In the SDK provided by Google, appcfg. py is used to upload applications to the Google App Engine. It can be called as follows:

Appcfg. pyUpdate ../Website

Or

Appcfg. py--Email=Xxx@gmail.com update ../Website

"../Website" is the directory where the application is located relative to the Command run directory. For example, the directory for running appcfg. py is "" iwebcache \ SRC \ Website ", so the ../website is used to indicate that the relative directory to be uploaded is website.

If you do not want to write Google's logon email for each upload, you can specify the -- email parameter.

5. to upload an application using appcfg. py, you also need a configuration file app. yaml.

Application: iwebcache
Version: 1
Runtime: Python
Api_version: 1

Handlers:
-URL:/
Script: Home. py

-URL:/Index \. html
Script: Home. py

-URL:/.*
Script: not_found.py

The specific user of the configuration file can see the link on the page, but here we should note that appcfg. PY checks the app before uploading files. the format of the yaml file is correct, but the problem is that

- URL: /
Script: Home. py

In this configuration, there must be two spaces before the script. Otherwise, an error will be reported.

Now, run the Upload Command to view your page. Googleappenginewebsite.rar

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.