将 Google 的云计算功能连接到 Apple 的 iPhone 中
2009-02-25 11:06:35 来源:WEB开发网上面这个代码片段将包含莎士比亚十四行诗的字典的内容转变成一个 XML plist,并将其提供给任何请求此 /plists/sonnets URL 的客户机。不管您相信与否,这就是我们的这个 Google App Engine 应用程序的主体。清单 2 给出了 sonnet.py 的一小部分。
清单 2. sonnet.py 的示例
verses={"verses":[["I","""FROM fairest creatures we desire increase,
That thereby beauty's rose might never die,
But as the riper should by time decease,
His tender heir might bear his memory:
But thou, contracted to thine own bright eyes,
Feed'st thy light'st flame with self-substantial fuel,
Making a famine where abundance lies,
Thyself thy foe, to thy sweet self too cruel.
Thou that art now the world's fresh ornament
And only herald to the gaudy spring,
Within thine own bud buriest thy content
And, tender churl, makest waste in niggarding.
Pity the world, or else this glutton be,
To eat the world's due, by the grave and thee."""]}
[NOTE: EDITED FOR SPACE]
main
函数将 URL /plists/sonnets 传递到类 MainHandler
。如果此客户机通过 HTTP GET
更多精彩
赞助商链接