Velpus Captiosus
Well-Known Coder
I have this HTML webpage:
and this python code.
I am using the
HTML:
<style>
button
{
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: medium;
color:black;
background-color: aliceblue;
border-style: hidden;
shape-outside: border-box;
cursor: default;
height: 36px;
width: 144px;
border-radius: 9px;
top: 500px;
left: 680px;
position: absolute;
}
button:hover
{
background-color: orangered;
}
</style>
<head>
<title>Sign in/Sign up</title>
</head>
<body background="backColorWebsite.png">
<form action="#" method="post">
<input type="text" name="Username" value="Username" style="font-family:Verdana, Geneva, Tahoma, sans-serif; background-color: aliceblue; position: absolute; top:250px;left:680px; width:144px; height:27px; border-radius: 9px; color:gray" maxlength="10"></input>
<input type="password" name="Password" value="Password" style="font-family:Verdana, Geneva, Tahoma, sans-serif; background-color: aliceblue; position: absolute; top:350px;left:680px; width:144px; height:27px; border-radius: 9px; color:gray" maxlength="10"></input>
<button>Sign In</button>
</form>
</body>
and this python code.
Python:
from flask import Flask,render_template,request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.app_context().push()
app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///db.sqlite3'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=False
db = SQLAlchemy(app)
class users(db.Model):
name = db.Column('name',db.String(100),primary_key=True)
password = db.Column('password',db.String(100))
role = db.Column('role',db.String(100))
def __init__(self,name:str,password:str,role:str):
self.name = name
self.password = password
self.role = role
with app.app_context():
db.create_all()
admin = users('Admin','RootRules99','Admin')
loggedInUsr:users
db.session.add(admin)
db.session.commit()
@app.route('/',methods=['POST','GET'])
def frontPage():
if request.method=='POST':
user = request.form['Username']
password = request.form['Password']
#found_user = users.query.filter_by(name=user,password=password).first()
return user,password
#if found_user:
#return 'Hello'
else:
return render_template('mywebsite.html')
I am using the
flask
library for python Web Programming.If I give out the credentials ['Username':'Admin' , 'Password':'Hi']
the webpage only prints out 'Admin' and it ignores completely the value given at the 'Password' input element.Why is this happenning?