Answer the question
In order to leave comments, you need to log in
How to display subprocess in Flask?
Guys, tell me, I'm a beginner in Python and Flask, I'm just starting, how to display Subprocess in the browser correctly?
For example, I write this
from app import app
import subprocess
@app.route('/')
@app.route('/index')
def index():
user = { 'nickname': 'MyName' }
p = subprocess.Popen("ping yandex.ru", stdout=subprocess.PIPE,)
out = p.communicate(str)
return '''
<html>
<head>
<title>MyFirstFlaskPage</title>
</head>
<body>
<h1>Hello, ''' + user['nickname'] + '''</h1>
<h1>Hello, ''' + out + '''</h1>
</body>
</html>
'''
from app import app
import subprocess
@app.route('/')
@app.route('/index')
def index():
#user = { 'nickname': 'Ivan' }
p = subprocess.Popen("ping yandex.ru", stdout=subprocess.PIPE,)
out = p.communicate(str)
return out
Answer the question
In order to leave comments, you need to log in
Hello, ''' + user['nickname'] + '''
Hello, ''' + str(out) + '''
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question