Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # how_many_days_service.py
- from flask import Flask, request, render_template
- app = Flask(__name__)
- NAME_IN_HTML_ELEMENT_FOR_USER_DATE =\
- "name_for_user_date"
- @app.route("/")
- def respond_to_root():
- bFormFilled:bool =\
- NAME_IN_HTML_ELEMENT_FOR_USER_DATE \
- in \
- request.args
- if (bFormFilled):
- the_date =\
- request.args[NAME_IN_HTML_ELEMENT_FOR_USER_DATE]
- r: str = f"<mark>Go the date {the_date}</mark>"
- return r
- else:
- return render_template("date_input.html")
- # def respond_to_root
- @app.route("/<pDate>", methods=['GET'])
- def respond_to_date(pDate:str):
- r:str=f"<mark>Go the date {pDate}</mark>"
- return r
- # def respond_to_date
- app.run(
- host="0.0.0.0",
- port=5556,
- debug=True
- )
- ***************
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Date Input</title>
- </head>
- <body>
- <form
- action="http://localhost:5556/"
- method="get"
- >
- <label for="id_the_user_date">Your date:</label>
- <input
- id="id_the_user_date"
- name="name_for_the_user_date"
- type="date"
- pattern="\d{4}-\d{2}-\d{2}"
- value="1969-06-21"
- >
- <input
- type="submit"
- value="submit date"
- >
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment