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