I'm implementing a Flask application and I need my app to run shell scripts, is the a way to do that?
I know that we can run shell commands this way :
from flask import Flask
import subprocess
app = Flask(__name__)
@app.route("/")
def hello():
cmd = ["ls","-l"]
p = subprocess.Popen(cmd, stdout = subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
out,err = p.communicate()
return out
if __name__ == "__main__" :
app.run()
But when it comes to a whole script how can I do that?