Reputation: 1526
As the first step in creating a cloud based mobile app I chose to try out the Google Cloud trial period. So as per the instructions in https://console.developers.google.com/start/appengine?_ga=1.92011098.1535487967.1418404546, I installed the Google cloud SDK and Google App engine and tried out the following code snippet as mentioned in the instructions.
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.'
As per instructions, I
gcloud auth login
gcloud components update gae-python
dev_appserver.py appengine-try-python-bottle
However, it generated the following logs (which I am not allowed to share here apparently because I haven't earned some points here) and localhost:8080 was blank. Can you please help me understand what am I missing here ?
Upvotes: 4
Views: 920
Reputation: 1068
Look here for an answer: https://github.com/GoogleCloudPlatform/appengine-bottle-skeleton
Those instructions worked perfectly for me.
Upvotes: 1
Reputation: 895
After putting bottle.py in the root directory and deploying it to GAE, the following code should work (template, static_file etc. will be probably useful for further development of the app so I am leaving them):
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()
Using bottle with GAE is not at all difficult, but in the long run it might be easier to use webapp2.
Upvotes: 1
Reputation: 470
Ok, for a starter, I think you shouldn't be using Bottle (or any other unsupported framework) on GAE. It's possible to use them, but it's not simple. It's what may be preventing your GAE app from starting. In all cases, we need more debug data!
Try using Webapp2. It was the first framework in python I ever used, but it was really simple to use (really, no more than Flask or Bottle). Here' the doc : https://cloud.google.com/appengine/docs/python/gettingstartedpython27/usingwebapp
If you really want to use Bottle, being a WSGI-compliant microframework, it's apparently not so hard to set it up on GAE. Maybe use this outdated tutorial to try and make it work. There's this github that might also help you bootstrap your project.
Upvotes: 0