30 lines
651 B
Python
30 lines
651 B
Python
import psycopg2
|
|
from flask import Flask, render_template, request
|
|
|
|
app = Flask(__name__)
|
|
app.debug = True
|
|
|
|
sql_statement = 'SELECT "id","title" FROM "Notes";'
|
|
HOST = '192.168.0.3'
|
|
DB = 'hackmd'
|
|
USER = 'hackmd'
|
|
PASSWORD = 'osHx34e4aDazGsER'
|
|
|
|
|
|
@app.route("/")
|
|
def main():
|
|
conn = psycopg2.connect(host=HOST, database=DB, user=USER, password=PASSWORD)
|
|
cur = conn.cursor()
|
|
cur.execute(sql_statement)
|
|
print("The number of parts: ", cur.rowcount)
|
|
res = cur.fetchall()
|
|
print(res)
|
|
cur.close()
|
|
conn.close()
|
|
return render_template('index.html',
|
|
notes=res)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run()
|