30 lines
757 B
Python
30 lines
757 B
Python
import psycopg2
|
|
from flask import Flask, render_template, request
|
|
|
|
app = Flask(__name__)
|
|
app.debug = True
|
|
|
|
sql_statement = 'SELECT "id","title","alias","shortid","viewcount","lastchangeAt" FROM "Notes";'
|
|
HOST = '192.168.0.3'
|
|
DB = 'hackmd'
|
|
USER = 'hackmd'
|
|
PASSWORD = 'osHx34e4aDazGsER'
|
|
CODI_URL = "https://hackmd.wiai.de"
|
|
#lastchangeAt, alias, viewcount
|
|
|
|
@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)
|
|
notes = cur.fetchall()
|
|
print(notes)
|
|
cur.close()
|
|
conn.close()
|
|
return render_template('index.html', notes=notes, host=CODI_URL)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run()
|