2016-12-16 119 views
0

正如標題所示,我在燒瓶應用試圖運行時看到這個錯誤。GAE/Flask [Errno 13] Permission denied

我在本地使用dev_appserver託管應用程序。

當我訪問該網站並嘗試運行該應用程序時發生該錯誤。看起來,由於某種原因,GAE正在嘗試並未能綁定套接字。

我懷疑這可能與OAuth2有關。也許它需要一個SSL連接?

我甚至不知道從哪裏開始解決這個問題,因爲沒有任何關於此問題的其他帖子正在經歷同樣的問題變化。

編輯:下面是控制檯的屏幕截圖,確認GAE服務器在其他端口上成功啓動;仍不能解決它

enter image description here

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 - 

代碼(如被看見在谷歌的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() 
+0

您是否試圖在本地計算機上運行此操作? – Nilesh

+0

你試過不同的端口嗎?端口可能正在使用中,或者在沒有根的情況下1024以下。 – kichik

+0

是的,我在本地運行它。因爲我只是遵循指南,所以我沒有在任何地方設置端口。該應用程序由GAE dev_appserver託管,默認使用端口8080 – Shaffanhoon

回答

1

我們有一個tutorial that walks you through adding Firebase Authentication to your Python app running with Flask。 Firebase身份驗證是現在的首選身份工具包。當然,您仍然可以使用純OAuth2流程,但如果您正在考慮向您的應用程序添加任何內容,Firebase Auth也會提供多供應商身份驗證。如果你只是想深入樣本代碼here on GitHub

如果你只是想堅持直接的OAuth,你可能想看看你自己的Flask代碼。 Getting flask to run is pretty easy on App Engine。我的猜測是你打電話給一些你不需要的代碼(flask.run()),或者你不是importing your library properly(見appengine_config.py)。

+0

Firebase解決方案看起來像我最終要走的方向,所以我將其標記爲答案。非常有幫助,謝謝! – Shaffanhoon

相關問題