
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
An easy way of setting up a redis connection in quart.
View the docs here.
# file: app.py
from quart import Quart
from quart_redis import RedisHandler, get_redis
app = Quart(__name__)
app.config["REDIS_URI"] = "redis://localhost"
# override default connection attempts, set < 0 to disable
# app.config["REDIS_CONN_ATTEMPTS"] = 3
redis_handler = RedisHandler(app)
@app.route("/")
async def index():
redis = get_redis()
val = await redis.get("my-key")
if val is None:
await redis.set("my-key", "it works!")
val = await redis.get("my-key")
return val
Due to quart_redis using before_serving
and after_serving
, using the Quart test_client
requires the use of test_app
. Pytest example shown below:
# file: test.py
import pytest
from app import app
@pytest.fixture(name="my_app", scope="function")
async def _my_app():
async with app.test_app() as test_app:
yield test_app
async def test_redis(my_app):
async with my_app.test_client() as client:
result = await client.get("/")
assert result == b"it works!"
For development and testing, you may not have a running Redis instance. In this case, the fakeredis
package may be installed and then used instead of actual redis by setting USE_FAKE_REDIS
environment variable to true at runtime.
FAQs
A easy way of setting up a redis in quart
We found that quart-redis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.