I'm tring to upload two files to server but the try except where I wrote in @app.route('result') is always in exception
from flask import Flask,render_template,redirect, url_for,request,redirect
import os, sys
from pymongo import MongoClient
from werkzeug import secure_filename
app = Flask(__name__,static_folder='static', static_url_path='')
import numpy
@app.route('/')
def showRoot():
return render_template('index.html')
@app.route('/result/')
def result():
return render_template('test.html')
ALLOWED_EXTENSIONS = set(['txt', 'docx', 'png', 'jpg'])
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
@app.route('/request_page/', methods=['GET','POST'])
def request_page():
UPLOAD_FOLDER = '/var/www/helloworldapp/app/uploads/'
UPLOAD_FOLDER = os.path.expanduser(UPLOAD_FOLDER)
if (not os.path.exists(UPLOAD_FOLDER)):
os.makedirs(UPLOAD_FOLDER)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
try:
Case_ID = '171129001'
mRNA_file = request.files['mRNA_file_name']
lncRNA_file = request.files['lncRNA_file_name']
if (mRNA_file != '' and allowed_file(mRNA_file.filename)) and (lncRNA_file != '' and allowed_file(lncRNA_file.filename)):
mRNA_file_name = Case_ID+secure_filename(mRNA_file.filename)
lncRNA_file_name = Case_ID+secure_filename(lncRNA_file.filename)
mRNA_file.save(UPLOAD_FOLDER+ mRNA_file_name)
lncRNA_file.save(UPLOAD_FOLDER + lncRNA_file_name)
#import sys
#sys.path.append('/var/www/helloworldapp/app')
#from . import Expression_profiles_preprocessing
#return(Expression_profiles_preprocessing.Concatenating_gene_expression_profile(Case_ID,mRNA_file_name,lncRNA_file_name))
else:
return 'Upload Failed'
except Exception as e:
return render_template('test.html', error=str(e))
the except result on my website is like this web result
Is there any solution to solve this problem? By the way , two files that upload by html can be seen in my server's document.