作为创建基于云的移动应用程序的第一步,我选择试用Google cloud试用期。因此,根据https://console.developers.google.com/start/appengine?_ga=1.92011098.1535487967.1418404546中的说明,我安装了Google cloud SDK和Google App engine,并尝试了说明中提到的以下代码片段。
from bottle import Bottle
bottle = Bottle()
# Note: We don't need to call run() since our application is embedded within
# the App Engine WSGI application server.
@bottle.route('/')
def hello():
"""Return a friendly HTTP greeting."""
return 'Hello World!'
# Define an handler for 404 errors.
@bottle.error(404)
def error_404(error):
"""Return a custom 404 error."""
return 'Sorry, nothing at this URL.'根据说明,我
gcloud auth login gcloud components update gae-pythondev_appserver.py appengine-try-python-bottle然而,它生成了以下日志(我显然不允许在这里分享,因为我没有在这里获得一些分数),localhost:8080是空白的。你能帮我理解一下我在这里错过了什么吗?
发布于 2016-04-28 21:37:14
在将bottle.py放入根目录并将其部署到GAE后,以下代码应该可以工作(模板、static_file等可能对应用程序的进一步开发有用,所以我将它们留下来):
from bottle import route,run,template, view, request,response
from bottle import static_file
from bottle import Bottle
from bottle import default_app
from bottle import url
@route('/login')
def getHandlerLogin():
return "<h1>Hello world</h1>"
app=default_app()将bottle与GAE一起使用并不困难,但从长远来看,使用webapp2可能会更容易。
发布于 2017-06-09 13:55:17
在这里寻找答案:https://github.com/GoogleCloudPlatform/appengine-bottle-skeleton
这些指令对我来说非常有效。
发布于 2014-12-23 18:35:58
好吧,作为一个初学者,我认为你不应该在GAE上使用Bottle (或任何其他不受支持的框架)。使用它们是可能的,但并不简单。这可能会阻止您的GAE应用程序启动。在所有情况下,我们都需要更多的调试数据!
尝试使用Webapp2。这是我使用过的第一个python框架,但它使用起来真的很简单(真的,不超过Flask或Bottle)。这里是文档:https://cloud.google.com/appengine/docs/python/gettingstartedpython27/usingwebapp
如果你真的想使用Bottle,它是一个符合WSGI的微框架,在GAE上设置它显然不是很难。也许可以使用this outdated tutorial来尝试让它工作。也有this github可以帮助你引导你的项目。
https://stackoverflow.com/questions/27450322
复制相似问题