(二)安装SDK1、下载https://developers.google.com/appengine/downloads,并安装速度比较慢,安装占用空间200M,python解释器的版本必须是2.7,暂不支持python 32、开发是要用的两个基本命令,安装已经被设置到path中去了dev_appserver.py # 开始开发一个webapp 项目appcfg.py #上载Web服务到云端容器。
(三)helloword程序1、新建项目目录hellword。2、新建文件helloword.py,内容如下:# -*- coding: utf-8 -*-import webapp2class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] ='text/plain' self.response.write('Hello, webapp2World!')application = webapp2.WSGIApplication([ ('/', MainPage),], debug=True)3、新建app.yaml,内容如下:application: your-app-idversion: 1runtime: python27api_version: 1threadsafe: true
handlers:- url: /.* script: helloworld.application
4、启动测试环境:(1)通过App Engine Launcher启动服务:通过开始菜单打开App Engine Launcher,file--add existingapplication,选在刚才新建的目录helloword,设置监听端口,本次是用的是8080和8081,点击run图标,启动服务,通过http://localhost:8080访问刚刚编写的helloword页面,通过http://localhost:8081访问管理页面。注意:点击图标“run”需要等待,“run”图标变成灰色以后,服务才可以访问。
(2)通过命令行启动服务:dev_appserver.py helloworld --port 8080 --admin_port8081更详细的信息可以参考dev_appserver.py --help。
5、部署服务:(1)通过AppEngine Launcher部署服务到 app engine:简单点击“deploy”按钮,提示输入邮箱和密码,按提示输入,... ,部署就完毕了。(2)通过命令行部署到服务器上:appcfg.py update app.yaml按提示输入账号密码,完成部署,(需要等30秒左右)。(3) appengine管理界面https://appengine.google.com/
![googleappengine:基础初探](http://img.aihuau.com/images/02111102/02122249t018173f0f7cab8470f.jpg)
6、访问app参考上说通过appid.appspot.com/访问应用,但是测试却无法访问使用代理也不行,目前还不知道原 因。搞了半天,ctm,居然被墙了。
参考:https://developers.google.com/appengine/docs/whatisgoogleappengine