From 665b66fe716e3da9429cd730165c0a9f06e779a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mihae=C4=BCs=20Mejerovs?= Date: Wed, 22 May 2024 17:19:35 +0000 Subject: [PATCH] Update flsk.py --- flsk.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/flsk.py b/flsk.py index 9fdd8e3..3c1bcc6 100644 --- a/flsk.py +++ b/flsk.py @@ -25,13 +25,12 @@ def about(): @app.route("/contact", methods=["GET", "POST"]) def contact(): if request.method == "POST": - # Get form data + name = request.form.get("name") email = request.form.get("email") message = request.form.get("message") - # Here you can process the message, send emails, save to database, etc. - # let's just print the data to the console + print(f"Name: {name}, Email: {email}, Message: {message}") return render_template("thank_you.html", name=name) @@ -45,18 +44,18 @@ def login(): username = request.form.get("username") password = request.form.get("password") - # Проверка, что поля не пустые + if username and password: return redirect(url_for('index', name=username)) else: - # Если поля пустые, оставляем пользователя на странице "login" + return render_template("login.html") return render_template("login.html") @app.route("/index") def index(): - # Здесь можно добавить логику для страницы "index" + return render_template("index.html") if __name__ == "__main__": @@ -102,7 +101,7 @@ if __name__ == "__main__": def get_weather_in_riga(): api_key = "e53814d3c7b076180e8d0273015b2804" - city_id = 456173 # ID города Рига + city_id = 456173 url = f"https://api.openweathermap.org/data/2.5/weather?id={city_id}&appid={api_key}&units=metric" response = requests.get(url)