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