Skip to content

Latest commit

 

History

History
116 lines (69 loc) · 2.62 KB

File metadata and controls

116 lines (69 loc) · 2.62 KB

Deploy on Render (FREE tier)

This project is a Flask web app, so on Render you should create a Web Service (not a Static Site).

1) Prerequisites

A) Make sure Gunicorn is installed

Render needs a production WSGI server. Add gunicorn to requirements.txt.

Example requirements.txt:

Flask==3.0.3
requests==2.32.3
gunicorn==22.0.0

B) Commit and push to GitHub

Render deploys from your repository, so push the latest changes.

2) Create the Render service

On Render:

  1. Click New +Web Service
  2. Select your GitHub repo
  3. Choose the branch (usually main)
  4. Pick Instance Type: Free

3) Configure commands (important)

Build Command

Use:

pip install -r requirements.txt

Start Command

Render’s autofill like gunicorn your_application.wsgi is not correct for this repo.

Use this exact command:

gunicorn -w 1 -b 0.0.0.0:$PORT app:app

Meaning:

  • app:app → file app.py, Flask object named app
  • $PORT → Render injects this environment variable automatically
  • -w 1 → single worker is safer here because this app uses a JSON file store

4) Deploy

Click Deploy Web Service.

After it finishes, open the provided Render URL.

5) Verify

  • Health endpoint: /health
  • Main UI: /

Important note about data persistence (Free tier)

This app stores links in data/url_store.db (SQLite).

On Render Free, instances can spin down and do not support persistent disks, so the database file can be lost on redeploy/sleep.

If you need the links to be reliably saved:

  • Use a paid instance with a persistent disk, or
  • Change storage to a database (e.g., SQLite/Postgres).

Common troubleshooting

A) “Application Error” or service keeps restarting

Most commonly the Start Command is wrong.

Double-check it is:

gunicorn -w 1 -b 0.0.0.0:$PORT app:app

B) “ModuleNotFoundError: gunicorn”

Add gunicorn==22.0.0 to requirements.txt, commit, push, redeploy.

C) TinyURL mirror sometimes fails

The TinyURL API call is an external request. If TinyURL is down or rate-limits you, the app may return tiny_url: null.

Optional configuration

You can set a custom database path using:

SHARPLINK_DB_PATH=/var/data/url_store.db

Rate limiting (recommended)

Configure a persistent rate limit backend (Redis):

RATELIMIT_STORAGE_URI=redis://:<password>@<host>:6379/0

If you don’t have Redis, the app will fall back to in-memory limits (not recommended for production).