How to set flask server?

Achtung! Help, I have a Flask server, whose main task, call in the system script with a parameter passed in the request. Here is the code:

import subprocess
from flask import Flask
from flask import Response

app = Flask(__name__)

@app.route("/<url>", methods=['GET'])
def index(url):
 cmd = './prg '
 cmd = cmd + url
 PIPE = subprocess.PIPE
 p = subprocess.Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE,
 stderr=subprocess.STDOUT, close_fds=True, cwd='/home/prog')
 resp = Response(
 resp.headers['Access-Control-Allow-Origin'] = '*'
 return resp 

if __name__ == "__main__":
 context = ('/var/www/httpd-cert/www-root/cert.crt', '/var/www/httpd-cert/www-root/cert.key')'', port=9090, ssl_context=context)</url>

Faced with a problem, my server crashes when it was accessed, what it can be connected? How to set this process optimally? It is worth noting that the program which is called computationally intensive, and runs not quite enough, using all available cores. (sometimes several minutes)
June 10th 19 at 14:52
1 answer
June 10th 19 at 14:54
You have done wrong. You can not block the thread of execution in the flask, as it single-threaded, then you are completely hang the server until the calculation of your assignment. For your task you need to run a parallel process, the data of this process is to put for example in a separate database or file, then give the result with the number of your process.
You can use any simple task queue type
Thank you) - maxwell_Monahan3 commented on June 10th 19 at 14:57

Find more questions by tags FlaskPython