Update flsk.py

main
Mihaeļs Mejerovs 2024-05-22 17:19:35 +00:00
parent 9ca58becb5
commit 665b66fe71
1 changed files with 6 additions and 7 deletions

13
flsk.py
View File

@ -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)