@app.route('/result/<case_id>')
def result(case_id):
USER_FOLDER = os.path.join(UPLOAD_FOLDER + '/' + Case_ID)
Analysis_code.main(USER_FOLDER, Case_ID, Case_ID + '_mRNA_file.txt', Case_ID + '_lncRNA_file.txt', Case_ID + '_miRNA_file.txt')
return render_template('test.html',case_id=Case_ID)
In my this result route, I call a function that are from another file.But when flask executed Analysis_code.main(), it didn't have enough time to run through the code.
In my Analysis_code.main(), the correlation def seemed like doesn't finish the save file job, and server return gateway timeout error back.
def main():
correlation(PATH, CASE_ID, mRNA_file_name, lncRNA_file_name, miRNA_file_name)
bipartite_network(PATH, CASE_ID)
Is there any way to solve this problem? I've searched about subprocess, but it seems like it's not suitable for me.
I am trying to figure out how to return the render_template and the def call from another python code can still finish in the background. Now, render_template has to wait for the function call finish so that it can return the webpage.
subprocessnot suitable here? Seems perfect if you don't need to return the result of the function in the response to the user.render_templateand the def call...can still finish in the background", but on the other hand "render_templatehas to wait for the function call finish so that it can return the webpage". Do you want to wait for the function to complete before the view function returns?