- 浏览: 2486720 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
google(一)python使用入门
我在google申请了帐号,呵呵,想试试在那里发布我新写的简单python应用。
首先学习google的python入门文档:
http://code.google.com/intl/zh-CN/appengine/docs/python/gettingstarted/
下载google的sdk
http://googleappengine.googlecode.com/files/google_appengine_1.3.0.zip
解开压缩文件,打开里面的readme,参考该文档安装环境,我的操作系统是ubuntu9.10
解开压缩后,将文件夹拷贝到工作目录
mv google_appengine/ /home/sillycat/tools/
1.撰写简单的hello world
创建目录
mkdir easyappenginepython
按照入门文档,我新建了文件helloworld.py,然后键入了如下内容:
print "Content-Type: text/plain"
print ""
print "Hello,sillycat!"
定义了google app engine需要的配置文件app.yaml,内容如下:
application: easyappenginepython
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: helloworld.py
切换到命令工具目录
cd /home/sillycat/tools
执行了命令:
google_appengine/dev_appserver.py /home/sillycat/work/easyappenginepython/
然后访问地址http://localhost:8080就看到了我的测试页面了。
2.使用webapp框架
按照文档上的描述,webapp包含三部分:
一个或多个 RequestHandler 类,用于处理请求和构建响应
一个 WSGIApplication 实例,按照网址将收到的请求发送给处理程序
一个主要例行程序,用于使用 CGI 适配器运行 WSGIApplication
新建package helloworld
新建文件helloworld/helloworld.py,内容如下:
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, sillycat webapp World!')
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
修改app.yaml配置文件:
application: easyappenginepython
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: helloworld/helloworld.py
启动服务:
切换到命令工具目录
cd /home/sillycat/tools
执行了命令:
google_appengine/dev_appserver.py /home/sillycat/work/easyappenginepython/
然后访问地址http://localhost:8080就看到了新页面了
webapp的详细描述
http://code.google.com/intl/zh-CN/appengine/docs/python/tools/webapp/
3.用户服务
参考文档,修改了helloworld.py文件如下:
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, you are ' + user.nickname())
else:
self.redirect(users.create_login_url(self.request.uri))
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
详细介绍用户API的文档:
http://code.google.com/intl/zh-CN/appengine/docs/python/users/
4.处理表单
简单的按照文档上,修改了helloworld.py如下:
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write("""
<html>
<body>
<form action="/sign" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Sign Guestbook"></div>
</form>
</body>
</html>""")
class Guestbook(webapp.RequestHandler):
def post(self):
self.response.out.write('<html><body>You wrote:<pre>')
self.response.out.write(cgi.escape(self.request.get('content')))
self.response.out.write('</pre></body></html>')
application = webapp.WSGIApplication(
[('/', MainPage),
('/sign', Guestbook)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
python运行时环境详细文档:
http://code.google.com/intl/zh-CN/appengine/docs/python/
我在google申请了帐号,呵呵,想试试在那里发布我新写的简单python应用。
首先学习google的python入门文档:
http://code.google.com/intl/zh-CN/appengine/docs/python/gettingstarted/
下载google的sdk
http://googleappengine.googlecode.com/files/google_appengine_1.3.0.zip
解开压缩文件,打开里面的readme,参考该文档安装环境,我的操作系统是ubuntu9.10
解开压缩后,将文件夹拷贝到工作目录
mv google_appengine/ /home/sillycat/tools/
1.撰写简单的hello world
创建目录
mkdir easyappenginepython
按照入门文档,我新建了文件helloworld.py,然后键入了如下内容:
print "Content-Type: text/plain"
print ""
print "Hello,sillycat!"
定义了google app engine需要的配置文件app.yaml,内容如下:
application: easyappenginepython
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: helloworld.py
切换到命令工具目录
cd /home/sillycat/tools
执行了命令:
google_appengine/dev_appserver.py /home/sillycat/work/easyappenginepython/
然后访问地址http://localhost:8080就看到了我的测试页面了。
2.使用webapp框架
按照文档上的描述,webapp包含三部分:
一个或多个 RequestHandler 类,用于处理请求和构建响应
一个 WSGIApplication 实例,按照网址将收到的请求发送给处理程序
一个主要例行程序,用于使用 CGI 适配器运行 WSGIApplication
新建package helloworld
新建文件helloworld/helloworld.py,内容如下:
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, sillycat webapp World!')
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
修改app.yaml配置文件:
application: easyappenginepython
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: helloworld/helloworld.py
启动服务:
切换到命令工具目录
cd /home/sillycat/tools
执行了命令:
google_appengine/dev_appserver.py /home/sillycat/work/easyappenginepython/
然后访问地址http://localhost:8080就看到了新页面了
webapp的详细描述
http://code.google.com/intl/zh-CN/appengine/docs/python/tools/webapp/
3.用户服务
参考文档,修改了helloworld.py文件如下:
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, you are ' + user.nickname())
else:
self.redirect(users.create_login_url(self.request.uri))
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
详细介绍用户API的文档:
http://code.google.com/intl/zh-CN/appengine/docs/python/users/
4.处理表单
简单的按照文档上,修改了helloworld.py如下:
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write("""
<html>
<body>
<form action="/sign" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Sign Guestbook"></div>
</form>
</body>
</html>""")
class Guestbook(webapp.RequestHandler):
def post(self):
self.response.out.write('<html><body>You wrote:<pre>')
self.response.out.write(cgi.escape(self.request.get('content')))
self.response.out.write('</pre></body></html>')
application = webapp.WSGIApplication(
[('/', MainPage),
('/sign', Guestbook)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
python运行时环境详细文档:
http://code.google.com/intl/zh-CN/appengine/docs/python/
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 430NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 291Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 373Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 334Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 415NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 359Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 292Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 208GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 390GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 275GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 264Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 259Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 252Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 235Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 233NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 225Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 517NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 229Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 319Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 320Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
资源名称:python基础教程至60课_python入门基础资料 内容简介:python基础教程至60课,这篇教程开始就为大家介绍了,为什么学习python,python有什么优点等,确实让你想快点学习python。为什么用Python作为编程...
在讲 Python 如何入门之前,个人建议最好每个人都有自己的 FQ 工具,多使用 Google 搜索,多去看一下墙外的世界,多看 Github 上的开源项目。 至于如何 FQ ,这里提供一下我用过的工具:FQ工具集 Python 学习资源...
mirror-quickstart-python, 面向 python的Google镜像快速入门 Google镜像快速入门 api快速入门的文档在 developers.google.com. 上维护有关更多信息,请参见这里: ...
Python的应用领域非常广泛,几乎所有大中型互联网企业都在使用 Python 完成各种各样的任务,例如国外的Google、Youtube、Dropbox,国内的百度、新浪、搜狐、腾讯、阿里、网易、淘宝、知乎、豆瓣、汽车之家、美团等等...
本教程所用的环境如下: 一、测试环境: 系统:64位win7中文版 浏览器:Google Chrome,尽量不要用IE浏览器,测试中可能不能使用。 Python:Anaconda3-4.3.1-Windows-x86_64.exe Python可以自行通过Baidu自行搜索...
本教程所用的环境如下: 一、测试环境: 系统:64位win7中文版 浏览器:Google Chrome,尽量不要用IE浏览器,测试中可能不能使用。 Python:Anaconda3-4.3.1-Windows-x86_64.exe Python可以自行通过Baidu自行搜索...
本教程所用的环境如下: 一、测试环境: 系统:64位win7中文版 浏览器:Google Chrome,尽量不要用IE浏览器,测试中可能不能使用。 Python:Anaconda3-4.3.1-Windows-x86_64.exe Python可以自行通过Baidu自行搜索...
Python是一种计算机程序设计语言。你可能已经听说过很多种流行的编程语言,比如非常难学的C语言,非常流行的Java语言,适合初学者的Basic语言,适合网页编程...连Google都在大规模使用Python,你就不用担心学了会没用。
Python崇尚优美、清晰、简单,是一个优秀并广泛使用的语言。Python在TIOBE排行榜中排行第八,它是Google的第三大开发语言,Dropbox的基础语言,豆瓣的服务器语言。Python的发展史可以作为一个代表,带给我许多启示。...
学习过程中有没有遇到什么困难 第⼀个困难就是python2.x和python3.x版本不兼容的问题,所以在编写代码时会出现语法报错,这些问题主要通过Bing和Google搜索即 可得到答案,作者也在书中给予了响应的提⽰;...
Python入门网络爬虫之精华版 Python学习网络爬虫主要分3个大的版块:抓取,分析,存储 另外,比较常用的爬虫框架Scrapy,这里最后也详细介绍一下。 首先列举一下本人总结的相关文章,这些覆盖了入门网络爬虫需要...
TensorFlow是Google公司2015年11月开源的第二代深度学习框架,是第一代框架DistBelief的改进版本. TensorFlow支持python和c/c++语言, 可以在cpu或gpu上进行运算, 支持使用virtualenv或docker打包发布. 定义变量 ...
Python项目开发实战入门,基于pygame包开发,资源来自明日学院
另外在国外,Yahoo和Google都在使用Python。那么,Python就很值得我们认真学习。 二、Hello,World! 首先我们需要安装Python,大家可以直接访问http://www.python.org/download ,下载Python的
《Head First Python(中文版)》不单纯是一本优秀的Python语言入门书,更棒的是,它充分展示了Python在现实世界中如何使用。这本书并不是罗列干巴巴的语法,它会教你如何为Android手机、Google App Engine等创建...
入门要开始使用此图像,请阅读我们自己使用,或浏览以获取想法。要求新包装首先,评估您自己在笔记本中安装软件包是否符合您的需求。 请参阅。 如果上述第一步不适用于您的用例,请或。打开拉取请求更新Dockerfile ...
《Python学习手册(第3版)》讲述了:Python可移植、功能强大、易于使用,是编写独立应用程序和脚本应用程序的...如果你准备探索Google和YouTube为什么选中了Python,《Python学习手册(第3版)》就是你入门的最佳指南。
本书包括: ·类型和操作——深入讨论python主要的内置对象类型:数字、列表和字典等。 ·语句和语法——在python中输入代码来建立并...如果你准备探索google和youtube为什么选中了python,本书就是你入门的最佳指南。