summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@turin.home>2022-02-03 18:23:37 +0000
committerroot <root@turin.home>2022-02-03 18:23:37 +0000
commit8600370a572ee933cf538cb3dd6fa7098f477c7c (patch)
treebdf5991438d828a88577043876c74b88bb2b34ff
parent1f9f9a4b5774afa2d9145f5f78fdff40eb500ff1 (diff)
Exporting to static file
-rw-r--r--main.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.py b/main.py
index f6bbb23..bfcb100 100644
--- a/main.py
+++ b/main.py
@@ -4,6 +4,7 @@ import errors
import sql
import weather
import time
+import sqlite3
from flask import Flask, render_template, redirect, url_for
from threading import Thread
@@ -75,14 +76,16 @@ def export_choice():
def export(opt):
# Defensive handling of input
if opt in ["temperature", "weather", "history", "schedule"]:
- con = sqlite3.connect(self.dbfile)
+ con = sqlite3.connect(DBFILE)
cur = con.cursor()
data = cur.exec("select * from {}".format(opt))
o = ""
for i in data:
o += str(a) + "\n"
con.close()
- return o
+ with open('static/export.txt', 'w') as file:
+ file.write(o)
+ return redirect('/static/export.txt')
else:
return render_template(
"error.html", error="Invalid export type"