0

I have created a GPS data processing application using flask framework. I have fully tested application in local virtual env and trying to host in heroku.

With this platform users can upload their files and get the processed file via email.

The problem is when user submitted the form it gives following error

An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.

To process data I have used a binary file which takes command line arguments and process the data based on user arguments.

I believe the problem is with the binary file

An equivalent question was asked by Dom Danks. But I am not sure how to follow the steps to overcome this issue based on the provided answer.

I have added only web: gunicorn app:app to the procfile do I have to add any other things?

@app.route('/', methods=['GET', 'POST'])
def SPP():
    SPP = My2Form()
    if request.method == 'POST':
        if SPP.validate_on_submit():

#Some codes to upload files to root folder

            submitted_file1 = request.files['sfileObsRover'] 
            submitted_file2 = request.files['sfileNavRover']
            a=submitted_file1.filename
            c=submitted_file2.filename
            selevation=str(SPP.sema.data)
            sFreq=SPP.sfrq.data
            emailAdd=SPP.semail.data
            filename1 = secure_filename(submitted_file1.filename)
            submitted_file1.save(os.path.join(app.config['UPLOAD_FOLDER'], filename1))
            filename2 = secure_filename(submitted_file2.filename)
            submitted_file2.save(os.path.join(app.config['UPLOAD_FOLDER'], filename2))

#End of the codes which related to file upload to root folder

#Generate a random file name for the out put
            y = str(randint(10000, 99999))+'.pos'

#Main processing function start ('rnx2rtkp' is a binary file which use to process data)

            command='rnx2rtkp -p 0 -m '+selevation+' -n -o '+y+' '+a+' '+c
            os.system(command)

#Use to delete files uploaded by user after processed file created

            os.remove(a)
            os.remove(c)

#Generated final processed file email to user

            email_user = ''
            email_password = ''
            recipientemail=emailAdd
            attachmentFile=y


            subject = 'subject'
            msg = MIMEMultipart()
            msg['From'] = email_user
            msg['To'] = recipientemail
            msg['Subject'] = subject

            body = 'This is your Post-Processed position file'
            msg.attach(MIMEText(body,'plain'))
            attachment  =open(attachmentFile,'rb')

            part = MIMEBase('application','octet-stream')
            part.set_payload((attachment).read())
            encoders.encode_base64(part)
            part.add_header('Content-Disposition',"attachment; filename= "+attachmentFile)

            msg.attach(part)
            text = msg.as_string()

            server = smtplib.SMTP('smtp.gmail.com',587)
            server.starttls()
            server.login(email_user,email_password)

            server.sendmail(email_user,recipientemail,text)
            server.quit()          

            return render_template('results.html', email=emailAdd, Name=SPP.sName.data, ema=selevation, frq=sFreq, pmode='Single Point Positioning')
    return render_template('SPP.php',SPP=SPP) 

I also have the source code for the rnx2rtkp application

Richiedlon
  • 111
  • 1
  • 4
  • 13
  • Check the logs, you can access them in your heroku app dashboard. Click on `more` (top right corner) and `view logs`. I am sure you missed something in the requirements.txt or procfile. – Roman Mar 15 '18 at 09:28
  • @Roman I have checked as you have mentiond. It specifies that rnx2rtkp is missing.`sh: 1: rnx2rtkp: not found`. BUt I have included rnx2rtkp.exe in root folder – Richiedlon Mar 15 '18 at 09:50
  • At least you know whats wrong now. With `.exe` on heroku its not that simple. I remember long time ago I had to add the wkhtml exe to heroku. I am not sure anymore, but I remember it had to be added in a special way, you should research in this direction. – Roman Mar 15 '18 at 10:58
  • @Roman Can you suggest me any other options that I can use to deploy this Flask application successfully – Richiedlon Mar 15 '18 at 14:04

0 Answers0