Explain me With proper simple css , routing and simple template rendering
// home page html <html> <body> <div class="container text-center"> <form action = "http://localhost:5000/l" method = "post"> <!-- CSS only --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> <h1 class="alert alert-success">Welcome to password Generator </h1> <h2>select the length and requirments for your password </h2> <select name="length"> <option value="4">select the lenght</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> </select> <br> <input type="checkbox"name="uppercase">uppercase <br> <input type="checkbox"name="numbers">numbers <br> <input type="checkbox"name="special">special <br> <input type="submit"value="generate password"class="btn btn-primary"> </form> </div> </body> </html> // password html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>fmirnirvn</title> </head> <body> <!-- CSS only --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> <div class="container text-center"> <h1><center>Password Generated successfully</center> </h1> <h1 class="alert alert-success">{{ da }}</h1> <input class="btn btn-warning" type="button" value="Generate New" onClick="window.location.reload(true)"> </div> </body> </html> // Backend password generator using Flask import random from flask import * app = Flask(__name__) @app.route('/l', methods=['POST']) def gen(): char=list('abcdefghijklmopqrstuvwxyz') if request.form.get('uppercase'): char.extend((list('ABCDEFGHILKLMNOPQRSTUVWXYZ'))) if request.form.get('special'): char.extend((list('!@#$%^&*()~'))) if request.form.get('numbers'): char.extend((list('1234567890'))) l =int(request.form['length']) thepass="" for i in range(l): thepass+=random.choice(char) return render_template('welcome.html',da=thepass) # return "<h1><center>password is generated %s </center><h1>" % thepass if __name__== '__main__': app.run(debug=True)
Muzamil_Raheman_31 <link href=“https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css” rel=“stylesheet” integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/
Can you explain what is this link refers to?
Muzamil_Raheman_31 char=list(‘abcdefghijklmopqrstuvwxyz’) if request.form.get(‘uppercase’): char.extend((list(‘ABCDEFGHILKLMNOPQRSTUVWXYZ’))) if request.form.get(‘special’): char.extend((list(‘!@#$%^&*()~’))) if request.form.get(‘numbers’): char.extend((list(‘1234567890’))) l =int(request.form[‘length’]) thepass="" for i in range(l): thepass+=random.choice(char) return render_template(‘welcome.html’,da=thepass)
In this backend code how frontend data is retrieved to backend to generate password?
Muzamil_Raheman_31 if request.form.get(‘uppercase’):
we have a “ request.form.get ” flask function to get the data from the frontend
PPRSREEKAR This is CDN link ( Content Delivery Network ) for bootstrap framework to achieve simple CSS , Like Container , buttons ect …
Muzamil_Raheman_31 Ok thank you bro