08bc888df07fdda5f0c5c52a500ce52a60bbfe73
Sunday Comics - Webcomic Flask App
A Flask-based webcomic website with server-side rendering using Jinja2 templates.
Features
- Comic viewer with navigation (First, Previous, Next, Latest)
- Archive page with thumbnail grid
- Responsive design
- Server-side rendering with Jinja2
- Clean, comic-focused layout
Project Structure
sunday/
├── app.py # Main Flask application
├── comics_data.py # Comic data (edit this to add comics)
├── requirements.txt # Python dependencies
├── scripts/ # Utility scripts
│ ├── add_comic.py # Script to add new comic entries
│ └── generate_rss.py # Script to generate RSS feed
├── templates/ # Jinja2 templates
│ ├── base.html # Base template with navigation
│ ├── index.html # Latest comic page
│ ├── comic.html # Individual comic viewer
│ ├── archive.html # Archive grid
│ ├── about.html # About page
│ └── 404.html # Error page
└── static/ # Static files
├── css/
│ └── style.css # Main stylesheet
├── images/ # Comic images
│ └── thumbs/ # Thumbnail images for archive
└── feed.rss # RSS feed (generated)
Setup
- Install dependencies:
pip install -r requirements.txt
- Run the application:
python app.py
- Visit http://127.0.0.1:3000 in your browser
Environment Variables
The app can be configured via environment variables:
SECRET_KEY- Flask secret key (defaults to 'your-secret-key')PORT- Port to run on (defaults to 3000)DEBUG- Enable debug mode (defaults to False)
Development:
export DEBUG=True
python app.py
Production:
export SECRET_KEY="your-secure-random-secret-key"
export PORT=3000
python app.py
Adding Comics
Comics are stored in the COMICS list in comics_data.py. Each comic entry:
{
'number': 1, # Comic number (required, sequential)
'filename': 'comic-001.png', # Image filename (required)
'date': '2025-01-01', # Publication date (required)
'alt_text': 'Alt text for comic', # Accessibility text (required)
'title': 'Comic Title', # Title (optional, shows #X if absent)
'author_note': 'Optional note' # Author note (optional)
}
Adding a New Comic
Option 1: Use the script (recommended)
python scripts/add_comic.py
This will automatically add a new entry with defaults. Then edit comics_data.py to customize.
Option 2: Manual
- Save your comic image in
static/images/(e.g.,comic-001.png) - Optionally, create a thumbnail in
static/images/thumbs/with the same filename - Add the comic entry to the
COMICSlist incomics_data.py
Generating RSS Feed
After adding comics, regenerate the RSS feed:
python scripts/generate_rss.py
This creates/updates static/feed.rss
Production Deployment
For production, you should NOT use Flask's built-in development server. Instead:
1. Generate a Secure Secret Key
python -c "import secrets; print(secrets.token_hex(32))"
2. Set Environment Variables
export SECRET_KEY="generated-secret-key-from-above"
export DEBUG=False
export PORT=3000
3. Use a Production WSGI Server
Install Gunicorn:
pip install gunicorn
Run with Gunicorn:
gunicorn app:app --bind 0.0.0.0:3000 --workers 4
4. Use a Reverse Proxy (Recommended)
Set up Nginx or another reverse proxy in front of Gunicorn for:
- HTTPS/SSL termination
- Static file serving
- Load balancing
- Better security
5. Additional Production Considerations
- Use a process manager (systemd, supervisor)
- Set appropriate file permissions
- Enable HTTPS with Let's Encrypt
- Consider using a CDN for static assets
- Monitor logs and performance
- Set up automated backups of
comics_data.py
Upgrading to a Database
For larger comic archives, consider replacing the COMICS list with a database:
- SQLite for simple setups
- PostgreSQL/MySQL for production
- Use Flask-SQLAlchemy for ORM support
Customization
Branding
- Update "Sunday Comics" references in
templates/base.html - Update site title and footer text
Styling
- Modify
static/css/style.cssto change colors, fonts, and layout - Current color scheme uses blue (#3498db) and dark blue-gray (#2c3e50)
About Page
- Edit
templates/about.htmlto add your bio and comic information
Pages
/- Shows the latest comic/comic/<id>- View a specific comic by number/archive- Browse all comics in a grid/about- About the comic and author/static/feed.rss- RSS feed
License
[Add your license here]
Languages
Python
31.7%
HTML
23.7%
JavaScript
23.5%
CSS
20.3%
Dockerfile
0.8%