我使用flask框架创建了一个GPS数据处理应用程序。我已在本地虚拟环境中完全测试了应用程序并尝试在heroku中托管。
通过此平台,用户可以上传文件并通过电子邮件获取处理过的文件。
问题是当用户提交form时会出现以下错误
应用程序中发生错误,您的页面无法执行 提供服务。如果您是应用程序所有者,请检查日志以获取详细信息。
为了处理数据,我使用了一个二进制文件,它接受命令行参数并根据用户参数处理数据。
我认为问题在于二进制文件
Dom Danks提出了一个同等的问题。但我不确定如何根据提供的答案按照步骤克服这个问题。
我只在web: gunicorn app:app
添加procfile
我是否需要添加其他内容?
@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)
我还有rnx2rtkp应用程序的源代码