Spaces:
Sleeping
title: Personal Blog
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
π Personal Blog
A clean, minimalist blog platform for sharing articles, code snippets, and engaging with readers through comments.
β¨ Features
- π° Article Publishing - Write and publish blog posts with Markdown support
- π» Code Snippets - Share code examples with syntax highlighting
- π¬ Comments System - Readers can leave comments on your articles
- π Dark/Light Mode - Toggle between themes with persistent preference
- π¨ Minimalist Design - Clean, distraction-free reading experience
- π·οΈ Tag Organization - Organize content with tags
- β‘ Fast & Lightweight - Built with FastAPI and vanilla JavaScript
- π± Responsive - Works beautifully on all devices
π Live Demo
Visit the blog: [Click "App" tab above]
Access admin panel: Add /admin.html to the URL
π οΈ Tech Stack
- Backend: FastAPI
- Storage: JSON files (persistent)
- Frontend: Vanilla JavaScript, HTML5, CSS3
- Markdown: Marked.js
- Syntax Highlighting: Highlight.js
π How to Use
For Readers
- Browse articles on the homepage
- Click any article to read the full content
- Leave comments at the bottom of articles
- Toggle dark/light mode with the π/βοΈ button
- View code snippets in the "Code Snippets" tab
For Authors (You!)
Option 1: Admin Panel (Easiest)
- Navigate to
/admin.html - Use the web interface to:
- Create new articles
- Add code snippets
- Preview content before publishing
- Manage existing articles
Option 2: API (Programmatic)
Create articles via API:
import requests
BLOG_URL = "YOUR_SPACE_URL"
article = {
"title": "My First Post",
"slug": "my-first-post",
"content": "# Hello World\n\nThis is my first blog post!",
"excerpt": "Introduction to my blog",
"tags": ["introduction"],
"published": True
}
requests.post(f"{BLOG_URL}/api/articles", json=article)
Or using curl:
curl -X POST YOUR_SPACE_URL/api/articles \
-H "Content-Type: application/json" \
-d '{
"title": "My Post",
"slug": "my-post",
"content": "# Content here",
"published": true
}'
Option 3: Direct File Edit
Edit data/articles.json directly in the Files tab.
π API Documentation
Interactive API docs available at /docs
Main Endpoints
GET /api/articles- List all published articlesGET /api/articles/{slug}- Get single articlePOST /api/articles- Create new articlePUT /api/articles/{id}- Update articleDELETE /api/articles/{id}- Delete articleGET /api/snippets- List code snippetsPOST /api/snippets- Create snippetGET /api/articles/{id}/comments- Get article commentsPOST /api/articles/{id}/comments- Add comment
βοΈ Writing in Markdown
Articles support full Markdown syntax:
# Heading 1
## Heading 2
**Bold** and *italic* text
- Bullet points
- Another point
1. Numbered lists
2. Second item
[Links](https://example.com)
`inline code`
```python
# Code blocks with syntax highlighting
def hello():
print("Hello World!")
Blockquotes
## π¨ Customization
### Update Your Info
Edit `static/index.html`:
```html
<h1>Your Name Here</h1>
<p class="subtitle">Your Title/Description</p>
Change Colors
Modify CSS variables in static/index.html:
:root {
--accent: #0066cc; /* Change accent color */
--bg-primary: #ffffff;
--text-primary: #1a1a1a;
}
Popular color schemes:
- Blue:
#0066cc(default) - Red:
#ff6b6b - Green:
#4ecdc4 - Purple:
#9b59b6 - Orange:
#f39c12
πΎ Data Storage
All data is stored in JSON files in the data/ directory:
articles.json- Blog postssnippets.json- Code snippetscomments.json- Reader comments
Important: These files persist across Space restarts. Download them periodically for backup.
π Project Structure
.
βββ app.py # FastAPI backend
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container configuration
βββ README.md # This file
βββ static/
β βββ index.html # Main blog interface
β βββ admin.html # Admin panel
βββ data/
βββ articles.json # Articles storage
βββ snippets.json # Snippets storage
βββ comments.json # Comments storage
π Security Notes
This is a simple blog without authentication:
β Anyone can:
- Read articles
- View snippets
- Post comments
β οΈ No protection for:
- Creating/editing articles via API
- Deleting content via API
For production: Consider adding:
- API key authentication
- Rate limiting
- Comment moderation
- CAPTCHA for comments
π Deployment
This blog is deployed on HuggingFace Spaces using Docker.
To deploy your own:
- Fork this Space or create a new one
- Choose "Docker" as SDK
- Upload all files
- Wait for build to complete
- Your blog is live!
π€ Contributing
Feel free to:
- Report bugs via the Community tab
- Suggest features
- Share your customizations
- Fork and improve!
π Example Articles
Sample article JSON:
{
"id": 1,
"title": "Getting Started with Python",
"slug": "getting-started-python",
"content": "# Python Basics\n\nPython is easy to learn...",
"excerpt": "Introduction to Python programming",
"tags": ["python", "tutorial"],
"published": true,
"created_at": "2024-01-20T10:00:00",
"updated_at": "2024-01-20T10:00:00"
}
π― Roadmap
Planned features:
- RSS feed generation
- Full-text search
- Article series/collections
- Social sharing buttons
- Reading time estimates
- View counters
- Email notifications for comments
- Markdown export/import
π License
MIT License - feel free to use this for your personal blog!
π Credits
Built with:
π§ Support
If you have questions or need help:
- Check the
/docsendpoint for API documentation - Visit the Community tab
- Review the admin panel at
/admin.html
Happy Blogging! β¨
Start writing your first post in the admin panel or via the API.
Quick Start Checklist
- Customize your name in
static/index.html - Write your first article via
/admin.html - Add a code snippet
- Test dark mode toggle
- Share your blog URL
- Backup your
data/folder - Start writing regularly!
Your blog is ready to go! π