All Projects → underyx → Flask Redis

underyx / Flask Redis

Licence: other
A Flask extension for using Redis

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Flask Redis

Bibi
An e-commerce fullstack solution for Flask 出口电商全栈解决方案
Stars: ✭ 914 (+139.9%)
Mutual labels:  redis, flask
Poopak
POOPAK - TOR Hidden Service Crawler
Stars: ✭ 78 (-79.53%)
Mutual labels:  redis, flask
X Proxies
Usable ip proxies, crawling from some proxy websites.
Stars: ✭ 53 (-86.09%)
Mutual labels:  redis, flask
Flask Session Tutorial
💾 🙇 Example Flask project for implementing Flask-Session with Redis.
Stars: ✭ 69 (-81.89%)
Mutual labels:  redis, flask
Chat
A simple chat app created to experiment with Redis, Gevent, Flask & Server-Sent Events.
Stars: ✭ 202 (-46.98%)
Mutual labels:  redis, flask
Invenio
Invenio digital library framework
Stars: ✭ 469 (+23.1%)
Mutual labels:  redis, flask
Flask And Redis
Simple as dead support of Redis database for Flask applications
Stars: ✭ 76 (-80.05%)
Mutual labels:  redis, flask
Enferno
A Python framework based on Flask microframework, with batteries included, and best practices in mind.
Stars: ✭ 385 (+1.05%)
Mutual labels:  redis, flask
Proxy pool
Python爬虫代理IP池(proxy pool)
Stars: ✭ 13,964 (+3565.09%)
Mutual labels:  redis, flask
Docker Flask Celery Redis
Docker-Compose template for orchestrating a Flask app with a Celery queue using Redis
Stars: ✭ 165 (-56.69%)
Mutual labels:  redis, flask
Flask Redis Queue
Example of how to handle background processes with Flask, Redis Queue, and Docker
Stars: ✭ 163 (-57.22%)
Mutual labels:  redis, flask
Flask Base
A simple Flask boilerplate app with SQLAlchemy, Redis, User Authentication, and more.
Stars: ✭ 2,680 (+603.41%)
Mutual labels:  redis, flask
Proxypool
An Efficient ProxyPool with Getter, Tester and Server
Stars: ✭ 3,050 (+700.52%)
Mutual labels:  redis, flask
Redis Monitor
💻 A very simple redis monitor based on Flask and React. 一个部署简单的 redis 监控程序,使用 Flask 和 React 完成。
Stars: ✭ 330 (-13.39%)
Mutual labels:  redis, flask
Flask Vuejs
Example & Tips, Flask with Vue.js.
Stars: ✭ 373 (-2.1%)
Mutual labels:  flask
Learning Resource
列出一些优秀的程序员学习资源
Stars: ✭ 378 (-0.79%)
Mutual labels:  redis
Tgcloud
Opensource Telegram based cloud storage
Stars: ✭ 371 (-2.62%)
Mutual labels:  redis
Pepy
pepy is a site to get statistics information about any Python package.
Stars: ✭ 369 (-3.15%)
Mutual labels:  flask
Cookiecutter Flask
A flask template with Bootstrap 4, asset bundling+minification with webpack, starter templates, and registration/authentication. For use with cookiecutter.
Stars: ✭ 3,967 (+941.21%)
Mutual labels:  flask
Multi Camera Live Object Tracking
Multi-camera live traffic and object counting with YOLO v4, Deep SORT, and Flask.
Stars: ✭ 375 (-1.57%)
Mutual labels:  flask

flask-redis

CircleCI codecov Codacy Badge GitHub tag (latest SemVer)

PyPI - Python Version Flask version support is 0.9+ redis-py version support is 2.6+ Code style: black

A nice way to use Redis in your Flask app.

Configuration

Start by installing the extension with pip install flask-redis. Once that's done, configure it within your Flask config. Set the URL of your Redis instance like this:

REDIS_URL = "redis://:[email protected]:6379/0"

If you wanna connect to a Unix socket, you can specify it like "unix://:[email protected]/path/to/socket.sock?db=0".

Usage

Setup

To add a Redis client to your application:

from flask import Flask
from flask_redis import FlaskRedis

app = Flask(__name__)
redis_client = FlaskRedis(app)

or if you prefer, you can do it the other way around:

redis_client = FlaskRedis()
def create_app():
    app = Flask(__name__)
    redis_client.init_app(app)
    return app

The FlaskRedis client here will pass its keyword arguments to the Redis class from the redis-py library, so all parameters from the Redis documentation page will work here as well — such as socket_timeout and encoding.

Accessing Redis

Access is done by using FlaskRedis as if it was a Redis class as well:

from my_app import redis_client

@app.route('/')
def index():
    return redis_client.get('potato')

For detailed instructions on what methods you can use on the client, as well as how you can use advanced features such as Lua scripting, pipelines, and callbacks, please check the redis-py documentation.

Pro-tip: The redis-py package uses the redis namespace, so it's nicer to name your Redis object something like redis_client instead of just redis.

Extra features in flask-redis

Custom providers

Instead of the default Redis client from redis-py, you can provide your own. This can be useful to replace it with mockredis for testing:

from flask import Flask
from flask_redis import FlaskRedis
from mockredis import MockRedis


def create_app():
    app = Flask(__name__)
    if app.testing:
        redis_store = FlaskRedis.from_custom_provider(MockRedis)
    else:
        redis_store = FlaskRedis()
    redis_store.init_app(app)
    return app

Contributing

  1. Check for open issues or open a fresh issue to start a discussion
  2. Fork the repository on GitHub.
  3. Send a pull request with your code!

Merging will require a test which shows that the bug was fixed, or that the feature works as expected. Feel free to open a draft pull request though without such a test and ask for help with writing it if you're not sure how to.

As Bence (the only maintainer) works full-time, please allow some time before your issue or pull request is handled.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].