【发布时间】:2016-12-16 21:28:40
【问题描述】:
正如标题所示,当我的烧瓶应用程序尝试运行时,我看到了这个错误。
我使用 dev_appserver 在本地托管应用程序。
当我访问该站点并尝试运行该应用程序时发生错误。似乎 GAE 出于某种原因尝试绑定套接字但失败。
我怀疑这可能与 OAuth2 有关。也许它需要 SSL 连接?
我什至不知道从哪里开始解决这个问题,因为其他关于这个问题的帖子都没有遇到同样的问题。
编辑:这是确认 GAE 服务器在不同端口上成功启动的控制台屏幕截图;还是没有解决
Traceback (most recent call last):
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "C:\Users\XXX\PycharmProjects\ad-assignment\main.py", line 51, in <module>
app.run()
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\flask\app.py", line 843, in run
run_simple(host, port, self, **options)
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 694, in run_simple
inner()
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 656, in inner
fd=fd)
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 550, in make_server
passthrough_errors, ssl_context, fd=fd)
File "C:\Users\XXX\PycharmProjects\ad-assignment\lib\werkzeug\serving.py", line 464, in __init__
HTTPServer.__init__(self, (host, int(port)), handler)
File "C:\Python27\Lib\SocketServer.py", line 417, in __init__
self.server_bind()
File "C:\Python27\Lib\BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "C:\Python27\Lib\SocketServer.py", line 431, in server_bind
self.socket.bind(self.server_address)
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\dist27\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\remote_socket\_remote_socket.py", line 676, in bind
raise _SystemExceptionFromAppError(e)
error: [Errno 13] Permission denied
INFO 2016-12-16 21:41:51,631 module.py:788] default: "GET /oauth2callback?code=x/xxxxxxxxxxxxxxxxx HTTP/1.1" 500 -
代码(见 Google 的OAuth2 usage guide):
import flask
app = flask.Flask(__name__)
@app.route('/')
def index():
...
@app.route('/oauth2callback')
def oauth2callback():
...
if __name__ == 'main':
import uuid
app.secret_key = str(uuid.uuid4())
app.debug = False
app.run()
【问题讨论】:
-
你想在本地机器上运行它吗?
-
您尝试了不同的端口吗?该端口可能正在使用中或在没有 root 的情况下低于 1024。
-
是的,我在本地运行它。我没有在任何地方设置端口,因为我只是按照指南进行操作。该应用程序由 GAE dev_appserver 托管,默认使用端口 8080
-
好吧,GAE 可能会尝试在已被其他服务使用的端口上运行,请在配置中配置端口作为评论中提到的@kichik。为了安全起见,我通常使用
9999。 -
我之前已经成功使用过 8080 端口。它之前使用 webapp2 框架,但后来我切换到了烧瓶。
标签: python google-app-engine flask