Created
January 25, 2022 12:57
-
-
Save nezuppo/c36bbb4c1f81da348ba74e8ccf3001bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import psycopg2 | |
from flask import ( | |
Flask, | |
Response, | |
) | |
DATABASE_URL = os.environ.get('DATABASE_URL') | |
app = Flask(__name__) | |
@app.route('/') | |
def root(): | |
with psycopg2.connect(DATABASE_URL) as conn: | |
with conn.cursor() as curs: | |
curs.execute('SELECT * FROM testtable') | |
result = curs.fetchall() | |
return Response(result[0][0]) | |
if __name__ == '__main__': | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: gunicorn app:app --log-file=- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gunicorn==20.1.0 | |
Flask==2.0.2 | |
psycopg2==2.9.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment