1

when trying to use

manifoldjs http://www.fox-poker.com

C:\Program Files (x86)\nodejs\node_modules\manifoldjs\node_modules\q\q.js:155 throw e; ^ TypeError: Object # has no method 'parse'


Why is my website throwing POST error in python?

I'm sending request to League of Legends API for JSON file. In 3 others tries it worked for me, but in last it doesn't. I have no idea why and can't find any mistakes.

My request for getting JSON file

def challengerPlayers(region, types, APIkey):
    URL = "https://" + region + ".api.pvp.net/api/lol/" + region + "/v2.5/league/master?type=" + types + "&api_key=" + APIkey
    response = requests.get(URL)
    return response.json()

My website function for return the results. Place, where is mistake, is highlighted with comment.

@app.route('/hello', methods=['post'])
def hello():
    region = request.form['region']
    summonerName = request.form['summonerName']
    APIkey = request.form['APIkey']
    types = request.form['types']
    responseJSON = getData(region, summonerName, APIkey)
    ID = responseJSON[summonerName]['id']
    ID = str(ID)
    responseJSON2 = getRankedData(region, ID, APIkey)
    divisionName = responseJSON2[ID][0]['name']
    responseJSON3 = challengerPlayers(region, str(types), APIkey)
    #Here is the problem ↓↓↓
    challengerPlayers = responseJSON3['entries'][0]
    #print challengerPlayers    
    return render_template('form_action.html', ID = ID,  divisionName = divisionName, challengerPlayers = challengerPlayers)

Last, but not least, my website form

<form class="form" method="post" action="/hello">
        <div class="form-group">
            <label for="regio">Region</label>
            <input type="text" name="region" />
        </div>
        <div class="form-group">
            <label for="summonerNam">Summoner Name</label>
            <input type="text" name="summonerName" />
        </div>
        <div class="form-group">
            <label for="apiKe">API Key</label>
            <input type="text" name="APIkey" />
        </div>
        <div class="form-group">
            <label for="type">Ranked type</label>
            <input type="text" name="types" />
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
    </form>

PS: Added JSON file

{
   "queue": "RANKED_SOLO_5x5",
   "name": "Nasus's Agents",
   "entries": [
      {
         "leaguePoints": 0,
         "isFreshBlood": false,
         "isHotStreak": false,
         "division": "I",
         "isInactive": false,
         "isVeteran": true,
         "losses": 402,
         "playerOrTeamName": "Ä  L  F  A",
         "playerOrTeamId": "28880245",
         "wins": 445
      }
  }
4

1 回答 1

1

确保你的机器上安装了最新版本的 Node,同时确保你的 ManifoldJS 版本是最新的。

如果仍然有问题,可以通过网站http://manifoldjs.com/生成 Node 工具输出的相同内容

于 2016-02-27T07:51:45.080 回答