2

ここの初心者-私はグーグルアプリエンジンを使用してボトルに「HelloWorld」を作成しようとしています。「helloworld」の部分が表示されましたが、インデックスページでも、「Hello world!Status:500」という出力が表示されます。
新しいルート(「/ page」ルートなど)を追加しようとすると、新しいルートに移動すると、「サーバーエラー:取得中にWebサイトでエラーが発生しました...メンテナンスのためにダウンしているか、正しく構成されていない可能性があります」というメッセージが表示されます。不適切に構成されたページに移動した後、「/」に戻ろうとすると、サーバーエラーも発生します。ルートディレクトリにbottle.pyを配置しました。誰かが私のファイルを正しく構成するのを手伝ってもらえますか?ありがとう!

import bottle 
from bottle import route, template, request, error, debug

@route('/')
def index():
    return "Hello World!"

@route('/page')
def page():
    return 'page!'

bottle.debug(True)
bottle.run(server='gae')
4

3 に答える 3

2

GAE でのボトルの優れたチュートリアルは次のとおりです: http://blog.rutwick.com/use-bottle-python-framework-with-google-app-engine

免責事項: チュートリアルは実行していませんが、正しいようです。

main.py:

from framework import bottle
from framework.bottle import route, template, request, error, debug
from google.appengine.ext.webapp.util import run_wsgi_app

@route('/')
def DisplayForm():
    message = 'Hello World'
    output = template('templates/home', data = message)
    return output

def main():
    debug(True)
    run_wsgi_app(bottle.default_app())

@error(403)
def Error403(code):
    return 'Get your codes right dude, you caused some error!'

@error(404)
def Error404(code):
    return 'Stop cowboy, what are you trying to find?'

if __name__=="__main__":
    main()

app.yaml:

application: my-bottle-app
version: 1
runtime: python
api_version: 1

handlers:
- url: /styles
  static_dir: styles

- url: /.*
  script: main.py

ご覧のとおり、サンプル コードとは多くの違いがあります。チュートリアルはそれらをうまく説明しているので、ここでは詳しく説明しません。

于 2012-10-02T20:41:08.890 に答える
2

これは役立つかもしれません:

app.yaml:

application: my-app
version: 1
runtime: python27
api_version: 1
threadsafe: yes

- url: .*
  script: main.app

main.py:

import bottle

@bottle.route('/')
def root():
    return 'hello!'

bottle.run(server='gae', debug=True)
app = bottle.app()

GitHub からの元の回答は次のとおりです。 https://github.com/defnull/bottle/issues/401

于 2012-11-17T20:14:59.137 に答える
0

App Engine + Bottle started codeのように WSGI を使用するbottle.debug()場合、コードが開発サーバーで実行されているときに呼び出すことができます。

import bottle
import os

DEBUG = os.environ.get('SERVER_SOFTWARE','').startswith('Development')  
bottle.debug(DEBUG)
app = bottle.Bottle()

そしてでapp.yaml

handlers:
- url: .*
  script: main.app
于 2016-01-24T20:39:04.213 に答える