GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - redis-developer/redis-starter-python: A starter project for working with Redis and Python

BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
__test__
__test__
 
 
src/app
src/app
 
 
.dockerignore
.dockerignore
 
 
.env.docker
.env.docker
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
compose.yml
compose.yml
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

This is a Redis starter template for Python using:

  • Redis Cloud
  • FastAPI

Requirements

  • make
  • python>=3.10
  • uv
  • docker
    • Optional outside tests

Getting started

Copy and edit the .env file:

cp .env.example .env

Your .env file should contain the connection string you copied from Redis Cloud.

Available settings:

  • APP_ENV=development|test|production
  • LOG_LEVEL=DEBUG|INFO|WARNING|ERROR|CRITICAL
  • LOG_STREAM_KEY=logs
  • PORT=8080
  • REDIS_URL=redis://...

For docker, .env.docker should use container-internal addresses. Example:

APP_ENV=production
LOG_LEVEL=INFO
LOG_STREAM_KEY=logs
REDIS_URL="redis://redis:6379"

Next, spin up docker containers:

make docker

You should have a server running on http://localhost:<port> where the port is set in your .env file (default is 8080). You can test the following routes:

  1. GET /api/todos - Gets all todos
  2. GET /api/todos/:id - Gets a todo by ID
  3. GET /api/todos/search?[name=<name>]&[status=<status>] - Search for todos by name and/or status
  4. POST /api/todos - Create a todo with { "name": "Sample todo" }
  5. PATCH /api/todos/:id - Update todo by ID with { "status": "todo|in progress|complete" }
  6. DELETE /api/todos/:id - Delete a todo by ID

Todos are serialized with JS-compatible camelCase timestamps:

  • createdDate
  • updatedDate

Validation and client errors use the JSON envelope:

{ "status": 400, "message": "Todo must have a name" }

Logging

Requests and component logs are written to stdout. They are also shipped to Redis as stream entries via XADD on the key configured by LOG_STREAM_KEY (default logs).

Running tests

The test suite lives in __test__ and can be run with:

make test

If REDIS_URL points at the default local Redis and nothing is listening on it, the tests will start the redis service with docker compose automatically and stop it afterward.

Running locally outside docker

Install dependencies and run the dev server:

make install
make dev

For a production-style server:

make serve

Other scripts

Run make to see the list of available commands.

Useful targets:

  • make format
  • make lint
  • make update
  • make lock

Connecting to Redis Cloud

If you don't yet have a database setup in Redis Cloud get started here for free.

To connect to a Redis Cloud database, log into the console and find the following:

  1. The public endpoint
  2. Your username
  3. Your password

Combine them into a connection string and put it in .env and .env.docker. Example:

REDIS_URL="redis://default:<password>@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####"

Run make test to verify the connection.

Learn more

  • Redis Documentation
  • Learn Redis
  • Redis Demo Center

About

A starter project for working with Redis and Python

redis.io/docs/latest/develop/clients/redis-py/

Topics

fastapipythonredisredis-pystartertemplateuv

Resources

Readme
Activity
Custom properties

Stars

10 stars

Watchers

3 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.