Skip to content

Latest commit

Β 

History

History
150 lines (101 loc) Β· 3.28 KB

File metadata and controls

150 lines (101 loc) Β· 3.28 KB

AI Blog Platform

A full-featured Flask-based Blog Application with user authentication, profile management, and post creation APIs. It uses Flask + SQLAlchemy on the backend and supports secure user sessions, CRUD operations for posts, and a clean frontend integration.

πŸš€ Features 🧍 User Management

Register new users with validations

Secure password hashing using Werkzeug

Login / Logout sessions

Profile update with bio, location, display name, and profile picture

Default Admin user auto-created (admin / admin123)

✍️ Blog Management

Create, Read, Update, Delete posts

View all posts or only logged-in user’s posts

Each post linked to an author

JSON APIs for integration with React or mobile apps

πŸ” Security

CSRF-safe design (session-based)

Secure headers (X-Content-Type-Options, X-Frame-Options, X-XSS-Protection)

Hashed passwords

Admin creation only via init_db()

🧩 API Blueprints

Organized routes:

/api/auth β†’ Authentication routes

/api/posts β†’ Blog routes

🧱 Project Structure πŸ“¦ advanced-blog/ β”œβ”€β”€ app1.py β”œβ”€β”€ static/ β”‚ β”œβ”€β”€ css/ β”‚ β”œβ”€β”€ js/ β”‚ └── images/ β”œβ”€β”€ templates/ β”‚ β”œβ”€β”€ index.html β”‚ β”œβ”€β”€ login.html β”‚ β”œβ”€β”€ register.html β”‚ β”œβ”€β”€ dashboard.html β”‚ β”œβ”€β”€ create_post.html β”‚ β”œβ”€β”€ my_posts.html β”‚ β”œβ”€β”€ edit_post.html β”‚ β”œβ”€β”€ view_post.html β”‚ └── profile.html └── advanced_blog.db (auto-generated)

βš™οΈ Installation & Setup 1️⃣ Clone Repository git clone https://github.com/yourusername/advanced-blog.git cd advanced-blog

2️⃣ Create Virtual Environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate

3️⃣ Install Dependencies pip install flask flask_sqlalchemy werkzeug

4️⃣ Run the Application python app1.py

πŸ“ Access at: πŸ‘‰ http://localhost:5000

πŸ”‘ Default Admin Credentials Username Password admin admin123 πŸ“‘ API Endpoints πŸ‘€ Authentication (/api/auth) Method Endpoint Description POST /register Register new user POST /login Login user POST /logout Logout user GET /user Get current logged-in user PUT /profile/update Update profile info πŸ“ Blog (/api/posts) Method Endpoint Description GET / Get all posts GET /my Get current user’s posts POST / Create a post GET /<post_id> Get a post by ID PUT /<post_id> Update a post DELETE /<post_id> Delete a post πŸ’Ύ Database

SQLite database advanced_blog.db is created automatically on the first run. Run init_db() manually if you need to reset the database.

πŸ’» Frontend Templates

The app serves HTML templates using Flask’s render_template(). These can be customized inside the templates/ folder to add:

Blog styling

User dashboard

Post editor

Profile page

πŸ”§ Environment Variables (Optional) Variable Description SECRET_KEY Flask session key (auto-generated if not set) SQLALCHEMY_DATABASE_URI Default: sqlite:///advanced_blog.db 🧠 Tech Stack

Backend: Flask (Python)

Database: SQLite + SQLAlchemy ORM

Frontend: HTML5 + CSS3 + JS (Flask Templates)

Security: Werkzeug password hashing, session-based auth

🧰 Future Improvements

JWT-based authentication

Image upload support for posts

AI-generated blog suggestions using OpenAI API

Comment and Like system

Admin analytics dashboard

🏁 License

MIT License Β© 2025