I'm new to flask and I'm making a webpage, where the user submits something and I need to run scripts with the using of the entered value.
2 questions:
Why don't make_nil gets called? - I'm getting the same value I entered.
Why don't i see sys.stdout('age: ', age) or print('age: ', age)?
Thanks!
flask_ager.py:
from flask import Flask, render_template, request
import sys
app = Flask(__name__)
@app.route('/send', methods=['GET', 'POST'])
def send():
if request.method == 'POST':
kapa = request.form['age']
age = make_nil(int(kapa))
sys.stdout('age: ', age)
return render_template('age.html', age=age)
return render_template('inka.html')
def make_nil(age):
return 0
if __name__ == "__main__":
app.run()
age.html:
<!DOCTYPE html>
<html>
<head> Siker? </head>
<body>
<h1> Your age is {{age}} </h1>
</body>
</html>
inka.html:
<!DOCTYPE html>
<html>
<head> Siker? </head>
<body>
<h1> How old are you? </h1>
<form method="POST" action="/send">
<div class="form_group">
<input type="text" name="age">
</div>
<input class="btn btn-primary" type="submit" value="submit">
</form>
</body>
</html>