getting data from db

master
Matt Huntington 3 years ago
parent 40121e73b9
commit 9660fa8df6

@ -4,16 +4,18 @@ import mariadb
mydb = mariadb.connect( mydb = mariadb.connect(
host="", host="",
user="", user="",
password="" password="",
database=""
) )
print(mydb) cursor = mydb.cursor()
app = Flask(__name__) app = Flask(__name__)
@app.get("/") @app.get("/")
def show(): def show():
return render_template('show.html') cursor.execute('SELECT * FROM items')
return render_template('show.html', cursor=cursor)
@app.post("/") @app.post("/")
def create(): def create():

@ -7,8 +7,11 @@
</head> </head>
<body> <body>
<ul> <ul>
{%for (id, title, description, created_at, updated_at, parent_id) in cursor%}
<li> <li>
{{title}}: {{description}}
</li> </li>
{%endfor%}
</ul> </ul>
<form action="/" method="POST"> <form action="/" method="POST">
<input name="title" type="text"> <input name="title" type="text">

Loading…
Cancel
Save