Update flsk.py
parent
a264010dc7
commit
c4707db0b6
44
flsk.py
44
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()
|
||||
app.run(debug=True)
|
Loading…
Reference in New Issue