T
url_for('foo', args1='something')
Size: a a a
T
url_for('foo', args1='something')
A
A
A
A
T
T
A
A
http://127.0.0.1/features/random/?number=250
A
http://127.0.0.1/features/random/?number=250
АП
http://127.0.0.1/features/random/?number=250
A
@app.route('/features/random/', methods=['POST', 'GET'])
def features_random_int():
if request.method == 'POST':
r_from = request.form['from']
r_to = request.form['to']
if r_from == '' or r_to == '':
res = 0
else:
r_from = int(r_from)
r_to = int(r_to)
if r_from > r_to:
res = randint(r_to, r_from)
elif r_from < r_to:
res = randint(r_from, r_to)
elif r_from == r_to:
res = r_from
else:
res = 0
return render_template('features/random.html', number=res)
else:
return render_template('features/random.html')
АП
A
AP
@app.route('/features/random/', methods=['POST', 'GET'])
def features_random_int():
if request.method == 'POST':
r_from = request.form['from']
r_to = request.form['to']
if r_from == '' or r_to == '':
res = 0
else:
r_from = int(r_from)
r_to = int(r_to)
if r_from > r_to:
res = randint(r_to, r_from)
elif r_from < r_to:
res = randint(r_from, r_to)
elif r_from == r_to:
res = r_from
else:
res = 0
return render_template('features/random.html', number=res)
else:
return render_template('features/random.html')
$.post('/features/random/', {
from: from,
to: to
}).done(function(response) {
# response - содержит return твоей функции
}
B
T
ПП
B
B