Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用google app engine部署瓶子应用程序时出现问题_Python_Google App Engine_Bottle - Fatal编程技术网

Python 使用google app engine部署瓶子应用程序时出现问题

Python 使用google app engine部署瓶子应用程序时出现问题,python,google-app-engine,bottle,Python,Google App Engine,Bottle,这里是新手——我一直在尝试使用谷歌应用引擎在瓶子里创建一个“你好世界”。我得到了要显示的“hello world”部分,但即使在索引页面上,我也得到了以下输出:“hello world!状态:500” 如果我尝试添加新路由(如“/page”路由),并导航到新路由,我会得到“服务器错误:网站在检索时遇到错误…可能是因为维护或配置不正确。”导航到配置不正确的页面后,如果我尝试返回“/”,我还会收到服务器错误。我已将瓶子.py放在我的根目录中。有人能帮我正确配置我的文件吗?谢谢 import bott

这里是新手——我一直在尝试使用谷歌应用引擎在瓶子里创建一个“你好世界”。我得到了要显示的“hello world”部分,但即使在索引页面上,我也得到了以下输出:“hello world!状态:500”
如果我尝试添加新路由(如“/page”路由),并导航到新路由,我会得到“服务器错误:网站在检索时遇到错误…可能是因为维护或配置不正确。”导航到配置不正确的页面后,如果我尝试返回“/”,我还会收到服务器错误。我已将瓶子.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')

下面是一个关于GAE的瓶子的好教程:

免责声明:我没有运行教程,但它看起来是正确的

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()
import bottle

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

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

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

handlers:
- url: /styles
  static_dir: styles

- url: /.*
  script: main.py
application: my-app
version: 1
runtime: python27
api_version: 1
threadsafe: yes

- url: .*
  script: main.app

如您所见,与示例代码有许多不同之处。本教程在解释它们方面做得很好,因此我在这里不详细介绍。

这是一个关于GAE上瓶子的好教程:

免责声明:我没有运行教程,但它看起来是正确的

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()
import bottle

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

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

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

handlers:
- url: /styles
  static_dir: styles

- url: /.*
  script: main.py
application: my-app
version: 1
runtime: python27
api_version: 1
threadsafe: yes

- url: .*
  script: main.app
如您所见,与示例代码有许多不同之处。本教程在解释它们方面做得很好,因此我在这里不详细介绍。

这可能会有帮助:

app.yaml:

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

handlers:
- url: /styles
  static_dir: styles

- url: /.*
  script: main.py
application: my-app
version: 1
runtime: python27
api_version: 1
threadsafe: yes

- url: .*
  script: main.app
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()
import bottle

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

bottle.run(server='gae', debug=True)
app = bottle.app()
以下是GitHub的原始答案。 这可能会有帮助:

app.yaml:

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

handlers:
- url: /styles
  static_dir: styles

- url: /.*
  script: main.py
application: my-app
version: 1
runtime: python27
api_version: 1
threadsafe: yes

- url: .*
  script: main.app
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()
import bottle

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

bottle.run(server='gae', debug=True)
app = bottle.app()
以下是GitHub的原始答案。

在中使用类似的WSGI时,当代码在开发服务器上运行时,可以调用
battle.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

在中使用WSGI时,当代码在dev服务器上运行时,可以调用
battle.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

发布实际错误的回溯。如果您在本地收到这些错误,请检查sdk输出,如果部署了,请检查错误日志。我也有同样的问题。当您使用Python 2.7并使用多线程时,则:A)如果处理程序为main.py:加载应用程序配置时出现致命错误:无法使用CGI处理程序main.py启用线程安全B)如果处理程序为main:Status 500,“module”不可调用C)如果将处理程序设置为main.app并将瓶子.app导入处理程序的范围,然后:调用应用程序时出错,args数无效,无法跟踪实际错误。如果您在本地收到这些错误,请检查sdk输出,如果部署了,请检查错误日志。我也有同样的问题。当您使用Python 2.7并使用多线程时,则:A)如果处理程序为main.py:加载应用程序配置时出现致命错误:无法使用CGI处理程序main.py启用线程安全B)如果处理程序为main:Status 500,“module”不可调用C)如果将处理程序设置为main.app并将瓶子.app导入处理程序的范围,然后:调用应用程序时出错,参数数无效