From c4707db0b6dc9fb467ac11bad851c4dd7c059f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mihae=C4=BCs=20Mejerovs?= Date: Thu, 23 May 2024 06:16:23 +0000 Subject: [PATCH] Update flsk.py --- flsk.py | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/flsk.py b/flsk.py index 3c1bcc6..52f5fd2 100644 --- a/flsk.py +++ b/flsk.py @@ -3,6 +3,13 @@ from flask import Flask, render_template, request, send_from_directory, redirect app = Flask(__name__) +@app.route('/index', methods=['GET', 'POST']) +def index(): + if request.method == 'POST': + print("sdfsdfsdfsdfs") + return render_template('index.html', show_text=True) + else: + return render_template('index.html', show_text=False) @app.route("/") @@ -25,12 +32,11 @@ def about(): @app.route("/contact", methods=["GET", "POST"]) def contact(): if request.method == "POST": - + name = request.form.get("name") email = request.form.get("email") message = request.form.get("message") - - + print(f"Name: {name}, Email: {email}, Message: {message}") return render_template("thank_you.html", name=name) @@ -43,43 +49,20 @@ def login(): if request.method == "POST": username = request.form.get("username") password = request.form.get("password") - if username and password: - return redirect(url_for('index', name=username)) + return redirect(url_for('index'),code=307) else: - return render_template("login.html") return render_template("login.html") -@app.route("/index") -def index(): - - return render_template("index.html") - -if __name__ == "__main__": - app.run() - - - @app.route('/') def button_page(): return render_template('login.html') -@app.route('/index', methods=['GET', 'POST']) -def display_text(): - if request.method == 'POST': - return render_template('index.html', show_text=True) - else: - return render_template('index.html', show_text=False) - -if __name__ == '__main__': - app.run(debug=True) - - def get_latvia_time(): @@ -92,11 +75,6 @@ def get_latvia_time(): except Exception as e: return f"Ошибка при получении времени: {e}" -if __name__ == "__main__": - latvia_time = get_latvia_time() - print(f"Текущее время в Латвии: {latvia_time}") - - def get_weather_in_riga(): @@ -119,4 +97,4 @@ def weather_route(): return get_weather_in_riga() if __name__ == "__main__": - app.run() \ No newline at end of file + app.run(debug=True) \ No newline at end of file