Skip to content

Commit

Permalink
feat: add redis test endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-fully-ported committed Nov 23, 2023
1 parent e01b867 commit a04ebc2
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions web.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""
starts a web process
"""
import os
import random

from cowsay import cowsay
from cowsay import get_random_cow
from flask import Flask
from flask import redirect
import redis
from flask import Flask, redirect

from shared import consume_cpu
from shared import consume_memory
from cowsay import cowsay, get_random_cow
from shared import consume_cpu, consume_memory

app = Flask(__name__)

Expand Down Expand Up @@ -46,5 +45,22 @@ def index(path):
return html, status_code


@app.route("/redis")
def redis_path():
"""
tests redis
"""

host = os.getenv("REDIS_HOST")
port = int(os.getenv("REDIS_PORT"))
password = os.getenv("REDIS_PASS")
connection = redis.Redis(
host=host, port=port, password=password, decode_responses=True
)
connection.set("foo", "bar")
html = f"<pre><code>{connection.get('foo')}</code></pre>"
return html, 200


if __name__ == "__main__":
app.run()

0 comments on commit a04ebc2

Please sign in to comment.