diff options
| author | root <root@turin.home> | 2022-02-03 18:23:37 +0000 |
|---|---|---|
| committer | root <root@turin.home> | 2022-02-03 18:23:37 +0000 |
| commit | 8600370a572ee933cf538cb3dd6fa7098f477c7c (patch) | |
| tree | bdf5991438d828a88577043876c74b88bb2b34ff | |
| parent | 1f9f9a4b5774afa2d9145f5f78fdff40eb500ff1 (diff) | |
Exporting to static file
| -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" |
