This is a FastAPI service template ready for deployment on Render.
- Install dependencies:
uv .venv
source .venv/bin/activate
uv pip install -r requirements.txt- Run the server:
uvicorn main:app --reloadThe API will be available at http://localhost:8000
Once the server is running, you can access:
- API docs (Swagger UI): http://localhost:8000/docs
- Alternative API docs (ReDoc): http://localhost:8000/redoc
GET /health- Health check endpointPOST /text- Submit a new text message{ "text": "Your message here" }GET /texts- Get all stored messages (newest first)- Optional query parameters:
skip: Number of records to skip (default: 0)limit: Maximum number of records to return (default: 10)
- Optional query parameters:
-
Create a PostgreSQL database on Render:
- Go to your Render dashboard
- Click "New +" and select "PostgreSQL"
- Choose a name for your database
- Select the free plan
- Click "Create Database"
- Save the "Internal Database URL" for the next step
-
Create a new Web Service on Render:
- Click "New +" and select "Web Service"
- Connect your GitHub repository
- Use the following settings:
- Build Command:
pip install -r requirements.txt - Start Command:
uvicorn main:app --host 0.0.0.0 --port $PORT
- Build Command:
- Add the environment variable:
- Key:
DATABASE_URL - Value: [Your Internal Database URL from step 1]
- Key:
-
Deploy your service:
- The service will automatically deploy when you push changes to your repository
- Your data will now persist in the PostgreSQL database
Use the provided test_api.py script to test your API:
- For local testing:
python test_api.py- For testing the deployed version:
- Edit
BASE_URLintest_api.pyto your Render service URL - Run the test script