I am new to python, I am trying to built a website with python, which is having 2 webpages. 'login.html' 'details.html'
But the user directly entering to details page without login also, how can I stop this?
I am able to do it when I am working with django using login_required, but when I am using cgi-bin script python, for webportal How can I stop this?
Please help me on this.
Here is the sample code:
login.html
<form action = "login1.py" method = "POST">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<br>
<br>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<br>
<br>
<br>
<button type="submit">Login</button>
details.html
<form action = "copy1.py" method = "POST">
<label for="phone num">Phone num:</label>
<input type = "text" name = "phone num"> <br />
<br >
<br >
<label for="email">Destination path :</label>
<input type = "text" name = "email" />
<br>
<br >
<br >
<div id=submit>
<input type = "submit" value = "Submit" />
login.py:
print("Content-type: text/html")
print("")
import cgi,cgitb
def func():
form = cgi.FieldStorage()
cgitb.enable()
username=form.getvalue('uname')
password = form.getvalue('psw')
userlist=[x,g,d]
passlist=[m,ldf]
if username in userlist:
if password in passlist:
redirectURL = "http://localhost/test/details.html"
print('<html>')
print(' <head>')
print(' <meta http-equiv="refresh" content="0;url='+str(redirectURL)+'" />')
print(' </head>')
print('</html>')
else:
print('<html>')
print('<div id="topcorner"> ')
print("please enter valid password")
print('</div>')
print('</html>')
else:
print('<html>')
print('<div id="topcorner"> ')
print("please enter valid username")
print('</div>')
print('</html>')
problem: without login also I am able to open details.html,user should authenticate first before going to some other site. Please help me on this