首页 > 解决方案 > Heroku 应用程序:来自 Heroku 应用程序的 REST API POST 请求返回错误 503,但它在本地工作

问题描述

user = '##'
pythonapp = '###'  #i have entered credentials here
url = 'https://##.com/wp-json/wp/v2'
credentials = user + ':' + pythonapp
token = base64.b64encode(credentials.encode())
headers = {'Authorization': 'Basic ' + token.decode('utf-8')}
post = { 'title': title,'status': 'publish','content': w,'format': 'standard'}
r = requests.post(url + '/posts', headers=headers, json=post)
return render_template('shortenurl.html', short1=aa,short=r)

它在本地运行烧瓶应用程序时工作正常。但是在 Heroku 应用程序上部署时显示 503 错误

注意:这是用于使用 python 和 REST API 在 wordpress 上创建帖子。

标签: wordpressflaskherokurestwordpress-rest-api

解决方案


推荐阅读