在本地机器上开发时,我使用standart代码来授权和使用Google磁盘
creds = None
cred = os.path.join(settings.BASE_DIR, 'credentials.json')
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
cred, SCOPES)
creds = flow.run_local_server(port=8080)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
我使用8080作为端口参数值。这很管用。在生产服务器上部署项目时,会收到一条消息port is already in use
。你知道吗
服务器:ubuntu18.04、Nginx、uwsgi
我应该使用什么值?你知道吗
升级版
我把端口改成了5000,所有东西都在本地机器上工作。我试着在生产服务器上运行它,结果出现了504错误。我检查了uwsgi日志,发现文件的末尾包含一个指向授权的链接。 在本地计算机上,此链接会自动在新窗口中打开以登录到帐户。如果再次尝试运行生产服务器,我将获得[Errno 98]地址already in use error,此错误将保存到重新启动uwsgi。重新启动后,一切都会再次重复。你知道吗
尝试netstat查看正在使用的端口。你知道吗
返回的任何端口都将显示上面的错误“端口已在使用中”。 任何其他端口都可以。 出于安全原因,最好使用1024以上的端口和非特权用户。django经常使用端口8000或端口8888,但可以使用任何端口。你知道吗
你也可以用插座。你知道吗
端口8078、8079和8080通常由tomcat/jetty等服务器应用程序使用。你知道吗
相关问题 更多 >
编程相关推荐