From 662649adec9439609fb137663dcc130f3f030b52 Mon Sep 17 00:00:00 2001 From: renan Date: Thu, 31 Mar 2022 21:03:34 -0400 Subject: [PATCH] Flask Redo Lab --- Code/renan/html_css_flask/9_flask/app.py | 18 +++++++--- .../9_flask/templates/index.html | 6 ++-- Code/renan/html_css_flask/flask_redo/app.py | 34 +++++++++++++++++++ .../flask_redo/templates/index.html | 14 ++++++++ 4 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 Code/renan/html_css_flask/flask_redo/app.py create mode 100644 Code/renan/html_css_flask/flask_redo/templates/index.html diff --git a/Code/renan/html_css_flask/9_flask/app.py b/Code/renan/html_css_flask/9_flask/app.py index 0ae965b9..be91659f 100644 --- a/Code/renan/html_css_flask/9_flask/app.py +++ b/Code/renan/html_css_flask/9_flask/app.py @@ -5,12 +5,22 @@ #localhost:5000/ @app.route('/') -def index(): - name = "Bill" - return render_template('index.html', name=name) +def index(): + return render_template('index.html') + + +#run flask app by below command inputs #$env:FLASK_APP= "app.py" +#py -m flask run +#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 + +#change the location of the webpage ..change the name from home to - /about +#previous route was just 5000/ which routed to index.html @app.route('/about') def about(): - return render_template('about.html') \ No newline at end of file + + return render_template('about.html') + + diff --git a/Code/renan/html_css_flask/9_flask/templates/index.html b/Code/renan/html_css_flask/9_flask/templates/index.html index 5ebd57bd..e4dcea3d 100644 --- a/Code/renan/html_css_flask/9_flask/templates/index.html +++ b/Code/renan/html_css_flask/9_flask/templates/index.html @@ -8,8 +8,8 @@ -

Welcome to my flask app

-

Hello {{name}}

- +

Welcom to My flask App

+ + \ No newline at end of file diff --git a/Code/renan/html_css_flask/flask_redo/app.py b/Code/renan/html_css_flask/flask_redo/app.py new file mode 100644 index 00000000..bd22125a --- /dev/null +++ b/Code/renan/html_css_flask/flask_redo/app.py @@ -0,0 +1,34 @@ +from flask import Flask, render_template +import random +import string + +app = Flask(__name__) + + +#localhost:5000/ +@app.route('/') +def index(): + + letters = str(string.ascii_lowercase) + # print(letters) + + digits = string.digits + # print(digits) + + punctuation = string.punctuation + # print(punctuation) + + all_characters = letters + digits + punctuation + # print(random.choice(all_characters)) + + # Password Generator + + characters = [] + + while len(characters) < 10: + characters.append(random.choice(all_characters)) + + password = characters + + + return render_template('index.html',password=password) diff --git a/Code/renan/html_css_flask/flask_redo/templates/index.html b/Code/renan/html_css_flask/flask_redo/templates/index.html new file mode 100644 index 00000000..ff4d6e3f --- /dev/null +++ b/Code/renan/html_css_flask/flask_redo/templates/index.html @@ -0,0 +1,14 @@ + + + + + + + Password Generatort + + +

Random Password Generator

+

Refresh Page To Get New Password

+

{{password}}

+ + \ No newline at end of file