https://github.com/arnobt78/blog--pyflask
BlogWebApp is a Python Flask blog application where users may authenticate, sign-in, log-in, log-out and post content. Other users can like or comment on the article, or the user can delete the posts and comments.
https://github.com/arnobt78/blog--pyflask
bootstrap css flask flask-api flask-application flask-backend flask-login flask-sqlalchemy font-awesome hmtl javascript python
Last synced: 7 months ago
JSON representation
BlogWebApp is a Python Flask blog application where users may authenticate, sign-in, log-in, log-out and post content. Other users can like or comment on the article, or the user can delete the posts and comments.
- Host: GitHub
- URL: https://github.com/arnobt78/blog--pyflask
- Owner: arnobt78
- Created: 2024-08-25T03:39:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-12T18:05:37.000Z (9 months ago)
- Last Synced: 2025-04-12T19:22:16.608Z (9 months ago)
- Topics: bootstrap, css, flask, flask-api, flask-application, flask-backend, flask-login, flask-sqlalchemy, font-awesome, hmtl, javascript, python
- Language: Python
- Homepage:
- Size: 294 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blog Application - PyFlask
    
---
## Project Summary
**Blog--PyFlask** is a beginner-friendly, full-stack blog web application built using Python's Flask web framework. The project demonstrates all core concepts of web development: routing, database modeling, authentication, CRUD (Create, Read, Update, Delete) operations, templates, and front-end integration with Bootstrap and Fontawesome. Designed for both learning and practical use, it allows users to register, log in, create blog posts, comment, like, and manage their content—all with a responsive user interface and secure access controls.
Whether you're new to Flask or web development in general, this project is a fantastic starting point for learning how modern web apps are structured and function.
---
## Table of Contents
1. [Project Summary](#project-summary)
2. [Features](#features)
3. [Technology Stack](#technology-stack)
4. [Project Structure](#project-structure)
5. [Installation & Getting Started](#installation--getting-started)
6. [Application Walkthrough](#application-walkthrough)
7. [Core Components & APIs](#core-components--apis)
8. [Examples: Usage & Code](#examples-usage--code)
9. [Customization & Further Development](#customization--further-development)
10. [Keywords](#keywords)
11. [Contributing](#contributing)
12. [License](#license)
13. [Conclusion](#conclusion)
---
## Features
- User registration and authentication (login/logout)
- Create, edit, and delete blog posts
- Comment on and like blog posts
- Delete comments (by post author or comment author)
- Responsive UI with Bootstrap and Fontawesome
- Basic access control (users can only delete/edit their own posts/comments)
- Error handling and user feedback messages
---
## Technology Stack
- **Backend:** Python, Flask
- **Frontend:** HTML, CSS, Bootstrap, Fontawesome
- **Database:** SQLite (default, easily configurable for others)
- **Templating:** Jinja2 (Flask's default)
- **Others:** Flask extensions for sessions, forms, database, etc.
---
## Project Structure
```
Blog--PyFlask/
│
├── app.py # Main Flask application entry point
├── requirements.txt # Python dependencies
├── README.md # Project documentation (you are here)
├── website/ # Main application package
│ ├── __init__.py # App factory & setup
│ ├── models.py # Database models (User, Post, Comment)
│ ├── routes.py # Routes (views/controllers)
│ ├── static/ # Static files (CSS, JS, images)
│ └── templates/ # HTML templates (Jinja2)
├── instance/ # Instance folder (configurations, dev db)
└── __pycache__/ # Python cache files
```
> Note: Some files/folders may be omitted for brevity.
---
## Installation & Getting Started
### 1. Clone the Repository
```sh
git clone https://github.com/arnobt78/Blog--PyFlask.git
cd Blog--PyFlask
```
### 2. Create and Activate a Virtual Environment
```sh
python -m venv .venv
# On Unix/macOS
source .venv/bin/activate
# On Windows
.venv\Scripts\activate
```
### 3. Install Dependencies
```sh
pip install -r requirements.txt
```
### 4. Run the Application
```sh
python app.py
```
By default, the app will be available at **http://127.0.0.1:5000**
---
## Application Walkthrough
1. **Register** a new account or **login** with existing credentials.
2. Once logged in, you can:
- Create a new blog post.
- View posts by all users.
- Like posts and add comments.
- Delete your own posts or comments.
3. Use the navigation bar to explore, create, and manage content.
Refer to the screenshots at the top for UI reference and expected features.
---
## Core Components & APIs
### app.py
- Entry point for the Flask application.
- Calls the app factory in `website/__init__.py`.
### website/__init__.py
- Configures and creates the Flask app instance.
- Sets up database, blueprints, and configuration.
### website/models.py
- Defines database models: `User`, `Post`, `Comment`.
- Example: User model stores username, email, password hash.
### website/routes.py
- Handles all routing (URLs):
- `/register`: Registration logic
- `/login`: Login logic
- `/logout`: Logout endpoint
- `/create-post`: Create new blog posts (auth required)
- `/post/`: View a single post and comments
- `/edit-post/`: Edit owned post
- `/delete-post/`: Delete owned post
- `/like-post/`: Like a post
- More...
### website/templates/
- All HTML templates, using Jinja2 for dynamic content.
- Inherits from a base layout for DRY code.
### website/static/
- Custom CSS, JS, and image files.
- Uses Bootstrap and Fontawesome for styling.
---
## Examples: Usage & Code
### Registering a User
```python
@app.route('/register', methods=['GET', 'POST'])
def register():
# Handles registration logic
```
### Creating a Post
```python
@app.route('/create-post', methods=['GET', 'POST'])
@login_required
def create_post():
# Handles new post creation
```
### Jinja2 Template Example
```html
{% block title %}Blog--PyFlask{% endblock %}
{% block content %}{% endblock %}
```
### Database Model Example
```python
# website/models.py
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(150), unique=True, nullable=False)
email = db.Column(db.String(150), unique=True, nullable=False)
password = db.Column(db.String(150), nullable=False)
posts = db.relationship('Post', backref='author', lazy=True)
```
---
## Customization & Further Development
- Switch to a different database (e.g., PostgreSQL) by updating config in `website/__init__.py`.
- Extend models for tags, categories, or user profiles.
- Implement user roles (admin/editor).
- Add more advanced front-end features or custom styles.
- Deploy to production with Gunicorn, Nginx, and a production database.
---
## Keywords
Python, Flask, Web Application, Blog, CRUD, Authentication, Bootstrap, HTML, CSS, Fontawesome, Jinja2, SQLite
---
## Contributing
Pull requests and feedback are welcome! For significant changes, please open an issue first to discuss what you would like to change.
---
## License
This project is for educational/demo purposes. For commercial or production use, review and update as needed.
---
## Conclusion
**Blog--PyFlask** is a practical, approachable example of a modern web application built with Flask. It covers all essential aspects of web development, from user authentication to front-end design, and is an ideal learning resource for students and developers new to Flask. Clone, run, and start hacking on your own blog today!
---
**Happy Coding!** 🚀
Thank you for exploring and learning with Blog--PyFlask!