Reputation: 723
Below is my code
view.py
from flask import render_template
#Import variables stored in _init_.py
from app import app
@app.route('/')
@app.route('/index')
def index():
import subprocess
memory = subprocess.Popen(['date'])
out,error = memory.communicate()
return render_template('view.html', out=out, error=error)
view.html
{{ out }}
It prints none, none, I am not sure what's wrong as it works fine in the python script
Update : Thanks for the answers, this is how you can do it
Upvotes: 1
Views: 4602
Reputation: 467
If you want to grab stdout from your command you need to add stdout=subprocess.PIPE as in:
memory = subprocess.Popen(['date'], stdout=subprocess.PIPE)
Upvotes: 2