-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
36 lines (30 loc) · 942 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import psycopg2
from flask import Flask, render_template, request, url_for, redirect
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
def get_db_connection():
conn = psycopg2.connect(host='localhost',
database='flask_db',
user=os.environ['DB_USERNAME'],
password=os.environ['DB_PASSWORD'])
return conn
# @app.route('/teams')
# def teams():
# conn = get_db_connection()
# cur = conn.cursor()
# cur.execute('SELECT * FROM teams;')
# teams = cur.fetchall()
# cur.close()
# conn.close()
# return render_template('teams.html', teams=teams)
# @app.route('/games')
# def games():
# conn = get_db_connection()
# cur = conn.cursor()
# cur.execute('SELECT * FROM games;')
# teams = cur.fetchall()
# cur.close()
# conn.close()
# return render_template('games.html', teams=teams)