Skip to content

Commit 662649a

Browse files
committed
Flask Redo Lab
1 parent 4eb9acd commit 662649a

File tree

4 files changed

+65
-7
lines changed

4 files changed

+65
-7
lines changed

Code/renan/html_css_flask/9_flask/app.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55

66
#localhost:5000/
77
@app.route('/')
8-
def index():
9-
name = "Bill"
10-
return render_template('index.html', name=name)
8+
def index():
119

10+
return render_template('index.html')
11+
12+
13+
#run flask app by below command inputs
1214
#$env:FLASK_APP= "app.py"
15+
#py -m flask run
16+
#You will need to run the flask app each time to refresh your page...1st kill your terminal by Ctrl + C then type py -m flask run
17+
1318

19+
#change the location of the webpage ..change the name from home to - /about
20+
#previous route was just 5000/ which routed to index.html
1421
@app.route('/about')
1522
def about():
16-
return render_template('about.html')
23+
24+
return render_template('about.html')
25+
26+

Code/renan/html_css_flask/9_flask/templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</head>
99
<body>
1010

11-
<h1>Welcome to my flask app</h1>
12-
<p>Hello {{name}}</p>
13-
11+
<h1>Welcom to My flask App</h1>
12+
13+
1414
</body>
1515
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from flask import Flask, render_template
2+
import random
3+
import string
4+
5+
app = Flask(__name__)
6+
7+
8+
#localhost:5000/
9+
@app.route('/')
10+
def index():
11+
12+
letters = str(string.ascii_lowercase)
13+
# print(letters)
14+
15+
digits = string.digits
16+
# print(digits)
17+
18+
punctuation = string.punctuation
19+
# print(punctuation)
20+
21+
all_characters = letters + digits + punctuation
22+
# print(random.choice(all_characters))
23+
24+
# Password Generator
25+
26+
characters = []
27+
28+
while len(characters) < 10:
29+
characters.append(random.choice(all_characters))
30+
31+
password = characters
32+
33+
34+
return render_template('index.html',password=password)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Password Generatort</title>
8+
</head>
9+
<body>
10+
<h1>Random Password Generator</h1>
11+
<p>Refresh Page To Get New Password</p>
12+
<p>{{password}}</p>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)