Flask restful API deploy on the Heroku with the dependencies

213 views Asked by At

I am getting below error when I deploy the Flask application on Heroku.

2020-10-11T05:28:50.452007+00:00 app[web.1]:  * Serving Flask app "app" (lazy loading)
2020-10-11T05:28:50.452050+00:00 app[web.1]:  * Environment: production
2020-10-11T05:28:50.452113+00:00 app[web.1]:    WARNING: This is a development server. Do not use it in a production deployment.
2020-10-11T05:28:50.452210+00:00 app[web.1]:    Use a production WSGI server instead.
2020-10-11T05:28:50.452246+00:00 app[web.1]:  * Debug mode: on
2020-10-11T05:28:50.462079+00:00 app[web.1]:  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2020-10-11T05:29:48.134889+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-10-11T05:29:48.151545+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-10-11T05:29:48.224518+00:00 heroku[web.1]: Process exited with status 137
2020-10-11T05:29:48.266775+00:00 heroku[web.1]: State changed from starting to crashed
2020-10-11T10:08:59.088712+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=qbdeployment.herokuapp.com request_id=7bf072d9-ed06-46ff-b463-797f74881a32 fwd="122.179.230.179" dyno= connect= service= status=503 bytes= protocol=https
2020-10-11T10:08:59.829982+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=qbdeployment.herokuapp.com request_id=7c158f7d-6ce3-44fe-87fd-24adfbfbd43e fwd="122.179.230.179" dyno= connect= service= status=503 bytes= protocol=https
2020-10-11T10:09:10.062949+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=qbdeployment.herokuapp.com request_id=fc43dec0-8976-45a6-bec7-87e749125436 fwd="122.179.230.179" dyno= connect= service= status=503 bytes= protocol=https
2020-10-11T10:09:10.678640+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=qbdeployment.herokuapp.com request_id=c61189c8-4ca8-4e73-8697-8279f69fefef fwd="122.179.230.179" dyno= connect= service= status=503 bytes= protocol=https
1

There are 1 answers

0
user On

yes i read the message, but the issue is i am calling the API to get the result

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)```