Welcome to your final project template! This is a starting point for building your own web application using Flask. Don't worry if some of this seems complex - you can build your project step by step, and there are example code blocks to help you along the way.
This template is set up for a basic blog website where you can:
- View all posts on the home page
- Create new posts
- Edit existing posts
- Delete posts
- Style your pages with CSS
You can modify this template to build something completely different! The core features (database, web pages, forms) can be adapted for many types of projects.
flask_learner_template/
├── static/ # CSS, images, etc.
│ └── css/
│ └── style.css # Pre-made styles you can use
│
├── templates/ # Your HTML files
│ ├── base.html # The main template other pages use
│ ├── home.html # Home page
│ ├── post.html # Single post view
│ ├── create.html # Create post form
│ └── edit.html # Edit post form
│
├── CODE_BLOCKS/ # Example code you can copy
│ ├── database/ # Database examples
│ ├── routes/ # Route examples
│ └── templates/ # Template examples
│
├── __init__.py # Makes Python treat this folder as a package
├── app.py # Your main application file
├── database.py # Database setup and functions
└── requirements.txt # Python packages needed
-
Make sure your virtual environment is activated (PyCharm should do this automatically)
-
Install the required packages:
pip install -r requirements.txt
-
Set up the database:
python database.py
This will create your database file and add some sample data.
-
Run the application:
python app.py
-
Open your browser and go to:
http://127.0.0.1:5000/
We're using these specific versions for stability:
- Flask==2.0.3
- Werkzeug==2.0.3
- flask-sqlalchemy==2.5.1
- Start by exploring the working blog example
- Look through the CODE_BLOCKS folder for examples
- Modify the HTML templates to change how pages look
- Update the CSS to style your pages
- Modify the database structure for your needs
- Add new routes in app.py for new features
Remember to:
- Test your changes frequently
- Keep your code organized
- Comment your code to explain what it does
- Ask for help if you get stuck!
You could modify this template to build:
- A personal portfolio
- An online store
- A recipe collection
- A movie review site
- A student club website
- A photo gallery
- ...or anything else you can think of!
- Check the comments in the code files
- Look at the example CODE_BLOCKS
- Ask your classmates
- Ask your instructor
- Google the error message if something's not working
- Start small and add features gradually
- Test each new feature before moving on
- It's okay to use the example code blocks - that's what they're for!
- Have fun building your project!
Good luck! Remember, every programmer started somewhere, and making mistakes is part of learning. 🌟