But after execution the only output i get is '1'. i guess this is because i have not made the code dynamic?? here is the html:
<html>
<body>
<form action = "http://localhost:5000/disp" method = "post">
<p>Enter Number:</p>
<p><input type = "number" name = "nm" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>
</body>
</html>
this is the flask:
from flask import Flask,redirect, url_for, request
import test
app = Flask(__name__)
@app.route('/disp',methods=['POST','GET'])
def printing():
if request.method == 'POST':
val = request.form['nm']
return test.pri(int(val))
if __name__ == '__main__':
app.run(debug=True)
and this is the python program:
import time
def pri(n):
for i in range(1,n):
return str(i)
sorry for asking a noob question
the problem is in pri(n) function. Within first iteration of 'for' function program hits return and ends. If you want response like "123456..." you can replace it with:
import time
def pri(n):
tmp = ""
for i in range(1,n):
tmp += str(i)
return tmp
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.