Answer the question
In order to leave comments, you need to log in
How to run a python script by passing it a calendar value in Flask?
Good day.
It is necessary that the user on the main page indicates the date in the calendar and clicks the submit button. After that, the script (test.py) was launched on the server, which accepted the date as str (for example) and executed. The problem is that I couldn't find how to execute the script with the passed parameter in Flask itself.
Please share the link, or suggest how to implement it :)
Answer the question
In order to leave comments, you need to log in
Um, I don't quite understand what "execute a script" means.
Perhaps you mean "call a function"?
Then form.birth_date.data must be passed to the function.
For example:
class EditUser(FlaskForm):
birth_date = DateField('Birthday Date', description='YYYY-MM-DD', format='%Y-%m-%d')
submit = SubmitField('Edit User')
def myfunc(birthday):
print(birthday)
@app.route('/edit', methods=['GET', 'POST'])
def edit_account():
form = EditUser()
if form.validate_on_submit():
myfunc(str(form.birth_date.data))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question