-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (32 loc) · 1.23 KB
/
app.py
File metadata and controls
47 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, request, redirect,make_response, render_template,session
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm
from wtforms.fields import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired
app = Flask(__name__)
bootstrap =Bootstrap(app)
app.config["SECRET_KEY"]= "SUPER SECRETO"
todos = ["comprar cafe ", "solicitud de compra ", "Traer"]
class LoginForm(FlaskForm):
username = StringField("Nombre de Usuario", validators=[DataRequired()])
password = PasswordField(" contraseña", validators=[DataRequired()])
submit = SubmitField("SEND")
@app.errorhandler(404)
def not_found(error):
return render_template("404.html", error=error)
@app.route("/")
def index():
user_ip = request.remote_addr
response = make_response(redirect('/hello'))
session["user_ip"] = user_ip
return response
@app.route('/hello', methods=["GET", "POST"])
def hello():
user_ip = session.get("user_ip")
login_form =LoginForm()
context = { "user_ip":user_ip,
"todos":todos,
"login_form": login_form}
return render_template("hello.html", **context, )
if __name__ == '__main__':
app.run(debug=True,port=5000)