diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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" |
