Skip to content

AnasHasan786/Flask-In-Action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask-In-Action 🚀

A comprehensive repository to learn and practice Flask by exploring various fundamental and advanced topics.

About This Repository

This repository is a collection of Flask scripts that I’ve created while learning Flask. It covers a wide array of concepts, ranging from the basics to advanced features, to help you gain hands-on experience with the Flask web framework.

Each topic is organized and well-documented, making it easy for anyone to follow and understand. Whether you’re a beginner or an intermediate learner, this repository is designed to be your one-stop resource for mastering Flask.

Flask


Table of Contents

  1. Getting Started
  2. Folder Structure
  3. Topics Covered
  4. How to Use This Repository
  5. Requirements

Getting Started

Clone this repository to your local system:

git clone https://github.com/your-username/Flask-In-Action.git
cd Flask-In-Action

Set up the virtual environment:

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

Folder Structure

Flask-In-Action/
│
├── blog/                # Contains a demo blog app for exploring Blueprints and views
├── templates/           # HTML templates for rendering
├── uploads/             # Directory for file uploads (e.g., images, documents)
├── user/                # User-related functionalities (authentication, sessions, etc.)
│
├── apis_with_json.py    # Example of building APIs and returning JSON
├── authentication.py    # User authentication using sessions and hashed passwords
├── blueprints_and_views.py  # Demonstrates the use of Blueprints and views
├── cookies.py           # Examples of using cookies in Flask
├── file_upload.py       # Demonstrates handling file uploads
├── hello.py             # A simple "Hello, World!" Flask app
├── http_methods.py      # Explores HTTP methods (GET, POST, etc.)
├── redirects_and_errors.py # Redirects and custom error pages
├── rendering_templates.py  # Examples of rendering Jinja2 templates
├── routing.py           # Basic routing and URL-building examples
├── sessions.py          # Managing user sessions
├── unique_urls.py       # Demonstrates unique URL generation
├── url_building.py      # Working with `url_for` to build dynamic URLs
├── variable_rules.py    # Demonstrates Flask's variable rules in routes
├── working_with_databases.py # Interacting with SQLite using Flask-SQLAlchemy
└── .gitignore           # Ignores unnecessary files from being committed

Topics Covered

1. Routing and URL Building

Learn how to create dynamic routes and use Flask's url_for function to generate URLs dynamically. Example: routing.py, url_building.py

2. Templates and Rendering

Understand how to use Jinja2 templates for dynamic content rendering. Example: rendering_templates.py, templates/

3. Sessions and Cookies

Manage user sessions and leverage cookies for storing client-side data. Example: sessions.py, cookies.py

4. Working with Databases

Use Flask-SQLAlchemy to interact with a database. Covers creating tables, adding data, and querying. Example: working_with_databases.py

5. Blueprints and Views

Learn how to modularize your Flask application using Blueprints for better structure. Example: blueprints_and_views.py

6. Authentication

Implement user authentication, including login, logout, and password hashing for security. Example: authentication.py

7. File Uploads

Handle file uploads securely, including saving files and validating their types. Example: file_upload.py

8. APIs with JSON

Build RESTful APIs and return JSON responses to clients. Example: apis_with_json.py

9. Redirects and Error Handling

Implement URL redirection and custom error pages for better user experience. Example: redirects_and_errors.py


How to Use This Repository

  1. Explore each .py file to understand the concept and its implementation.
  2. Run the Flask app for a particular topic and test it in the browser. For example:
flask --app routing.py run --debug
  1. Check the templates/ folder for HTML files used in template rendering.

Requirements

  • Python 3.8 or higher
  • Flask
  • Flask-SQLAlchemy
  • Jinja2

Install the dependencies using:

pip install -r requirements.txt

Thank you for exploring this repository.

About

This repository covers the essential concepts of Flask development, including routing, templates, forms, and database integration, enabling you to quickly create and deploy a basic Flask application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors