def execute():
print("this is imam")
#perform some task after first print then print next function
print('this akarsh')
#perform some task after first print then print next function
print('this is abhi')
@app.route('/')
def home ():
return render_template('index.html', x= execute())
I just wanted to print the upper three print statements on my html page i have tried with the set variable to pass, please help me with this. As it prints on python console one after the other performing certain task as mentioned.
def execute():
return """
this is imam
this akarsh
this is abhi
"""
If you are using index.html
as a template. It should look like this:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h3>This is a parameter from app</h3>
{{ x }}
</body>
</html>
and you have to change your execute()
function like this:
def execute():
x = 'this is imam'
print("this is imam")
#perform some task after first print then print next function
y = 'this akarsh'
print('this akarsh')
#perform some task after first print then print next function
z = 'this is abhi'
print('this is abhi')
result = [x,y,x]
return result
You can use a list (or any python data structure) to return your results.
You can use this method
Outposts
class class Outpost: def __init__(self): self.outposts = [] def add_outpost(self, data): self.outposts.append(data)
execute()
function and run execute()
: execute_outposts = Outpost() execute()
execute_outposts.add_outpost(text)
execute_outposts.outposts
in x
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.