Hello I am studying python recently and a newbie ,I am unable set a logic to as, if the post data does not qualify,post page will be redirected to origin page. After a long time search I found this how to redirect one page to another ,But still having confusion regarding redirecting page. here is my html code :
<form action="generate_timing_data.py" method="POST">
<p>Select an athlete from the list to work with:
</p><input type="radio" name="which_athlete" value="Mikey McManus"> Mikey McManus<br />
<input type="radio" name="which_athlete" value="Julie Jones"> Julie Jones<br />
<input type="radio" name="which_athlete" value="James Lee"> James Lee<br /><input type="radio" name="which_athlete" value="Sarah Sweeney"> Sarah Sweeney<br /><p>
</p><input type=submit value="Select">
</form>
And this is my python code :
import cgi
import athletemodel
import yate
form_data = cgi.FieldStorage()
if form_data['which_athlete'].value != '':
//calculation stuff
else :
//redirect stuff
In here, where to put header code and all the staff in form and how to redirect to origin page from the post page, how to set all the things? please help me to understand how the process flow?
And a kind request please don't downvote,I am newer in python.
I did lot of R&D and finally found this and would be the perfect solution so far.If you feel not appropriate ,please correct it.Thank you