Update flsk.py

main
Mihaeļs Mejerovs 2024-05-23 06:16:23 +00:00
parent a264010dc7
commit c4707db0b6
1 changed files with 11 additions and 33 deletions

44
flsk.py
View File

@ -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()
app.run(debug=True)