Automate Reddit posting with a Flask web app + a background worker that publishes using Playwright.
- Create scheduled Reddit posts from a web UI.
- Store scheduled jobs in SQLite.
- Auto-publish posts when their scheduled time arrives.
- Publish immediately or cancel pending posts.
- Save logs and debug artifacts when something fails.
PythonFlaskSQLAlchemyPlaywright(browser automation)SQLite
- Python
3.10+recommended pip- Access to a Reddit account
- Chromium installed via Playwright
git clone <REPO_URL>
cd Reddit-Auto-Post-RaspberryOn Windows (PowerShell):
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txtOn Linux / Raspberry Pi:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtpython -m playwright install chromiumIf you're on Raspberry Pi/Linux and system libraries are missing, try:
python -m playwright install --with-deps chromium
Copy the example file:
cp .env.example .envOn Windows PowerShell:
Copy-Item .env.example .envAvailable variables:
| Variable | Default value | Description |
|---|---|---|
APP_HOST |
0.0.0.0 |
Flask server host |
APP_PORT |
5000 |
Web app port |
DEBUG |
True |
Flask debug mode |
SECRET_KEY |
(empty) | Flask session signing key. Required if LOGIN_PASSWORD is set. |
LOGIN_PASSWORD |
(empty) | Optional access code for dashboard protection. |
DATABASE_URL |
sqlite:///data/app.db |
SQLite database URL |
MAX_CONTENT_LENGTH |
10485760 |
Upload size limit (bytes) |
LOG_FILE_PATH |
logs/worker.log |
Worker log file |
PLAYWRIGHT_HEADLESS |
False |
Run browser without UI |
PLAYWRIGHT_AUTH_FILE |
playwright/.auth/reddit.json |
Saved Reddit session |
WORKER_POLL_SECONDS |
30 |
Worker polling interval (seconds) |
DEBUG_ARTIFACTS_DIR |
logs/debug |
Screenshots/HTML on Playwright errors |
CAPABILITIES_CACHE_TTL_HOURS |
24 |
Capabilities cache TTL in hours |
If you want to prevent other users on your LAN from seeing your dashboard:
- Set
LOGIN_PASSWORDin.envwith your access code. - Set
SECRET_KEYin.env(any long random string). - Restart the web app.
Behavior:
LOGIN_PASSWORDempty or missing: dashboard remains open (no login screen).LOGIN_PASSWORDset: dashboard is protected by/loginand browser session cookie.LOGIN_PASSWORDset butSECRET_KEYmissing: app fails fast at startup with a config error.
Before publishing, save an authenticated Reddit session:
python -m app.scripts.reddit_loginA browser window will open:
- Log in to Reddit manually.
- Return to the terminal and press
ENTER. - Session state will be saved to
playwright/.auth/reddit.json.
Open 2 terminals (with the virtual environment activated in both):
python -m app.mainpython -m app.workerThen open:
- Create a post from
Create new post. - Fill in title, subreddit, date/time, and optionally image/text.
- Save the post.
- The worker publishes it when status is
pendingand time is due. - From the detail page, you can
Publish noworCancelwhile pending.
.jpg.jpeg.png.webp
| Problem | Common cause | Fix |
|---|---|---|
Playwright authentication file not found |
Login script not run yet | Run python -m app.scripts.reddit_login |
Post button is disabled |
Reddit UI validation or captcha/protection page | Check logs/debug/ and try PLAYWRIGHT_HEADLESS=False |
| Nothing gets published | Worker not running or no due posts | Start python -m app.worker and verify status/scheduled UTC |
| Image upload error | Unsupported format or invalid path | Use jpg/jpeg/png/webp and upload again |
app/
main.py # Flask web app
worker.py # Polling-based auto publisher
web/ # Routes and templates
services/ # Publishing, logging, validation, storage logic
repositories/ # Data access layer
scripts/ # Manual scripts (login/testing)
data/ # SQLite DB and uploads (runtime-generated)
logs/ # Logs and debug artifacts
playwright/.auth/ # Saved Reddit session
# Save Reddit session
python -m app.scripts.reddit_login
# Publish directly via script
python -m app.scripts.reddit_post <subreddit> "<title>" "<body>" "<image_path_1>" "<image_path_2>" ...- The datetime from the form is converted internally to UTC.
- The repo ignores
data/,logs/, and.envto avoid committing sensitive/local files. - For 24/7 Raspberry deployment, running web + worker as services is recommended.