Skip to content
Snippets Groups Projects
Commit 3a1e3104 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Better formatting for get request

parent c10679a3
No related branches found
No related tags found
No related merge requests found
......@@ -256,7 +256,13 @@ def get():
conn = sqlite3.connect(config["database"]["path"])
cursor = conn.cursor()
visitors = get_records(conn, cursor)
visitors = "\n".join([str(v) for v in visitors])
table = []
table.append("<table>")
table.append("<tr><th>location</th><th>entrance</th><th>direction</th><th>time</th><th>id</th></tr>")
for v in visitors:
table.append("<tr><td>{}</td><td>{}</td><td>{}</td><td>{}</td><td>{}</td></tr>".format(v["location"], v["entrance"], v["direction"], v["time"], v["id"]))
table.append("</table>")
table = "\n".join(table)
conn.close()
app.logger.info('200, Get visitors: {}'.format(visitors))
return visitors, 200
\ No newline at end of file
app.logger.info('200, Get visitors: {}'.format(table))
return table, 200
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment