Skip to content

Commit

Permalink
feat: add a postgres test
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-fully-ported committed Nov 23, 2023
1 parent 8426814 commit b47c26f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Flask
pg8000
python-cowsay
redis[hiredis]
21 changes: 21 additions & 0 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import random

import pg8000.native
import redis
from flask import Flask, redirect

Expand Down Expand Up @@ -67,5 +68,25 @@ def redis_path():
return html, 200


@app.route("/postgres")
def postgres_path():
"""
tests postgres
"""

host = os.getenv("DB_HOST")
port = int(os.getenv("DB_PORT"))
password = os.getenv("DB_PASS")
username = os.getenv("DB_USER")
con = pg8000.native.Connection(
user=username, password=password, host=host, port=port
)
for row in con.run("SELECT 1"):
html = f"<pre><code>ping redis with tls: {row}</code></pre>"

con.close()
return html, 200


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

0 comments on commit b47c26f

Please sign in to comment.