に動作していない私は、複数のパラメータを使用しようとした場合Pythonのフラスコ要求は、複数のパラメータを指定して
作業from flask import Flask, request
@app.route('/test', methods=['GET', 'POST'])
def test():
req_json = request.get_json(force=True)
UserName = req_json['username']
UserPassword = req_json['password']
return str(UserName)
を働いていない
私は、PythonのAPIを使用しようとしたが、そのは動作していません
from flask import Flask, request
@app.route('/test', methods=['GET', 'POST'])
def test():
req_json = request.get_json(force=True)
UserName = req_json['username']
return str(UserName)
エラー
https://www.herokucdn.com/error-pages/application-error.html
ログ
State changed from crashed to starting
2017-07-11T06:44:13.760404+00:00 heroku[web.1]: Starting process with command `python server.py`
2017-07-11T06:44:16.078195+00:00 app[web.1]: File "server.py", line 29
2017-07-11T06:44:16.078211+00:00 app[web.1]: account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
2017-07-11T06:44:16.078211+00:00 app[web.1]: ^
2017-07-11T06:44:16.078213+00:00 app[web.1]: IndentationError: unexpected indent
2017-07-11T06:44:16.179785+00:00 heroku[web.1]: Process exited with status 1
2017-07-11T06:44:16.192829+00:00 heroku[web.1]: State changed from starting to crashed
Server.py
import os
from flask import Flask, request
from twilio.jwt.access_token import AccessToken, VoiceGrant
from twilio.rest import Client
import twilio.twiml
ACCOUNT_SID = 'accountsid'
API_KEY = 'apikey'
API_KEY_SECRET = 'apikeysecret'
PUSH_CREDENTIAL_SID = 'pushsid'
APP_SID = 'appsid'
app = Flask(__name__)
@app.route('/test', methods=['GET', 'POST'])
def test():
req_json = request.get_json(force=True)
UserName = req_json['username']
Password = req_json['password']
return str(UserName)
@app.route('/accessToken')
def token():
req_json = request.get_json(force=True)
IDENTITY = req_json['identity']
account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
api_key = os.environ.get("API_KEY", API_KEY)
api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)
push_credential_sid = os.environ.get("PUSH_CREDENTIAL_SID", PUSH_CREDENTIAL_SID)
app_sid = os.environ.get("APP_SID", APP_SID)
grant = VoiceGrant(
push_credential_sid=push_credential_sid,
outgoing_application_sid=app_sid
)
token = AccessToken(account_sid, api_key, api_key_secret, IDENTITY)
token.add_grant(grant)
return str(token)
@app.route('/outgoing', methods=['GET', 'POST'])
def outgoing():
resp = twilio.twiml.Response()
#resp.say("Congratulations! You have made your first oubound call! Good bye.")
resp.say("Thanks for Calling! Please try again later.")
return str(resp)
@app.route('/incoming', methods=['GET', 'POST'])
def incoming():
resp = twilio.twiml.Response()
#resp.say("Congratulations! You have received your first inbound call! Good bye.")
resp.say("Thanks for Calling! Please try again later.")
return str(resp)
@app.route('/placeCall', methods=['GET', 'POST'])
def placeCall():
req_json = request.get_json(force=True)
IDENTITY = req_json['identity']
CALLER_ID = req_json['callerid']
account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
api_key = os.environ.get("API_KEY", API_KEY)
api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)
client = Client(api_key, api_key_secret, account_sid)
call = client.calls.create(url=request.url_root + 'incoming', to='client:' + CALLER_ID, from_='client:' + IDENTITY)
return str(call.sid)
@app.route('/', methods=['GET', 'POST'])
def welcome():
resp = twilio.twiml.Response()
resp.say("Welcome")
return str(resp)
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port, debug=True)
質問を適切なエラーの説明と完全なエラートレースバックで完了してください。 –
あなたはそれを読んで、与えられた助言に従うべきです。 –
詳細ログを追加してくれてありがとうございました – PinkeshGjr