Flask Restful API通过依赖项部署在Heroku上

时间:2020-10-11 10:15:14

标签: flask heroku flask-restful heroku-postgres heroku-api

在Heroku上部署Flask应用程序时,我遇到了错误消息。

JwtClaimValidator<URL>

1 个答案:

答案 0 :(得分:0)

是的,我阅读了消息,但是问题是我正在调用API来获取结果

from flask import request, jsonify


app = flask.Flask(__name__)
app.config["DEBUG"] = True

# Create some test data for our catalog in the form of a list of dictionaries.

@app.route('/', methods=['GET'])
def home():
    return '''<h1>WELCOME</h1>
<p>Get all pppp hhhh insterted and delected text from the word document.</p>'''

@app.route('/api', methods=['GET'])


def api_id():
    import requests
    import xmltodict
    import pprint
    import json
    from zipfile import ZipFile
    from urllib.request import urlopen
    from io import BytesIO
#     from zipfile import *
    from bs4 import BeautifulSoup
    import pandas as pd
    
    if 'Id' in request.args:
        Id = request.args['Id']
        print(type(Id))
    else:
        return "Error: No id field provided. Please specify an id."
    results = []
    url='https://bps.quickbase.com/db/****?a=API_GetRecordInfo&rid='+Id+'&fmt=structured&usertoken=****'
    #url='https://builderprogram-pverma.quickbase.com/db/bqscz87a5?a=API_GetRecordInfo&rid='+Id+'&fmt=structured&usertoken=b5fdma_nx3z_pzc2d4b2uvnihbayfyd8bk8swsk'
    response = requests.request("GET", url)
    print(response)
    r=response.text.encode('utf8')
    print(r)
    pp = pprint.PrettyPrinter(indent=4)
    data=json.dumps(xmltodict.parse(r))
    data1=json.loads(data)
    for i in data1.values():
        for j in i['field']:
            if j['fid']=="11":
                Document=j['value']
            if j['fid']=="3":
                R_Id=j['value']
        Mapped_data={R_Id :Document}
#         print(Mapped_data)
#         return Mapped_data
    track_changed_for_del=[]
    track_changed_for_ins=[]
    for key, value in Mapped_data.items():
        wordfile=urlopen(value).read()
        wordfile=BytesIO(wordfile)
        document=ZipFile(wordfile)
        document.namelist()
        xml_content=document.read('word/document.xml')
        wordobj=BeautifulSoup(xml_content.decode('utf-8'),'xml')
        key_record=key
        for dl in wordobj.find_all('w:del'):
            Text=dl.text
            author=dl.get('w:author')
            Date=dl.get('w:date')
            Type='Deleted Text'
            ID=dl.get('w:id')
            ID=int(ID)
            dataDict_del = { 'Text':Text,'Author':author,'Date':Date,'Type':Type,'ID':ID,'Record_Id':key_record}
            print(dataDict_del)
            track_changed_for_del.append(dataDict_del)
        for ins in wordobj.find_all('w:ins'):
            Text=ins.text
            author=ins.get('w:author')
            Date=ins.get('w:date')
            Type='Inserted Text'
            ID=ins.get('w:id')
            ID=int(ID)
            dataDict_ins = { 'Text':Text,'Author':author,'Date':Date,'Type':Type,'ID':ID,'Record_Id':key_record}
            track_changed_for_ins.append(dataDict_ins)
        df_track_changed_ins= pd.DataFrame(track_changed_for_ins)
        df_track_changed_del= pd.DataFrame(track_changed_for_del)```