summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-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"