This project demonstrates two ways of serving a personal profile page with Flask:
-
Basic Approach:
- Uses
basic.pyto serve a single HTML file (basic.html) viasend_from_directory. - No dynamic parameters or redirects.
- Uses
-
Advanced Approach:
- Uses
advanced.pywith Flask’srender_templateto serveadvanced.html. - Redirects from
/to/profileand injects parameters (name, description) into the template.
- Uses
- We created two Python files (
basic.pyandadvanced.py) to showcase both simple and more advanced serving methods in Flask. - We built two HTML pages (
basic.htmlandadvanced.html), each demonstrating a different approach. - A
requirements.txtfile is included to specify the dependencies needed for this project (primarily Flask). - We also included a
static/folder containing CSS and image files.
-
Clone the Repository:
git clone <repo url> cd <repo-name>
-
install Dependancies
pip install -r requirements.txt -
run the basic version
python basic.py -
run the advanced version
python advanced.py
Go to http://127.0.0.1:5000/. You’ll be redirected to /profile, where you’ll see the Advanced page with dynamic parameters.
.
├── basic.py
├── advance.py
├── requirements.txt
├── static
│ ├── style.css
│ └── me.jpg
└── templates
├── basic.html
└── advance.html