FrederickSundeep commited on
Commit
c0da950
·
1 Parent(s): d96f137

update file 016

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from flask import Flask, request, jsonify, send_file, render_template
2
  from transformers import pipeline
3
  from langchain.prompts import PromptTemplate
4
  from reportlab.pdfgen import canvas
@@ -8,7 +8,6 @@ import uuid
8
  import sqlite3
9
  import csv
10
  import zipfile
11
- from flask import Response, send_from_directory
12
  from io import BytesIO
13
 
14
  app = Flask(__name__)
@@ -141,7 +140,7 @@ def view_tickets():
141
  page = int(request.args.get("page", 1))
142
  per_page = 10
143
 
144
- conn = sqlite3.connect("tickets.db")
145
  c = conn.cursor()
146
 
147
  query = "SELECT * FROM tickets WHERE 1=1"
@@ -170,7 +169,7 @@ def view_tickets():
170
 
171
  @app.route("/export/csv")
172
  def export_csv():
173
- conn = sqlite3.connect("tickets.db")
174
  c = conn.cursor()
175
  c.execute("SELECT * FROM tickets")
176
  rows = c.fetchall()
@@ -178,7 +177,7 @@ def export_csv():
178
 
179
  output = BytesIO()
180
  writer = csv.writer(output)
181
- writer.writerow(["ID", "First Name", "Last Name", "Email", "Issue", "Priority", "Date", "Filename"])
182
  writer.writerows(rows)
183
 
184
  output.seek(0)
@@ -194,7 +193,5 @@ def export_zip():
194
  zip_io.seek(0)
195
  return send_file(zip_io, mimetype="application/zip", as_attachment=True, download_name="tickets.zip")
196
 
197
-
198
-
199
  if __name__ == "__main__":
200
  app.run(host="0.0.0.0", port=7860)
 
1
+ from flask import Flask, request, jsonify, send_file, render_template, Response
2
  from transformers import pipeline
3
  from langchain.prompts import PromptTemplate
4
  from reportlab.pdfgen import canvas
 
8
  import sqlite3
9
  import csv
10
  import zipfile
 
11
  from io import BytesIO
12
 
13
  app = Flask(__name__)
 
140
  page = int(request.args.get("page", 1))
141
  per_page = 10
142
 
143
+ conn = sqlite3.connect(DB_PATH)
144
  c = conn.cursor()
145
 
146
  query = "SELECT * FROM tickets WHERE 1=1"
 
169
 
170
  @app.route("/export/csv")
171
  def export_csv():
172
+ conn = sqlite3.connect(DB_PATH)
173
  c = conn.cursor()
174
  c.execute("SELECT * FROM tickets")
175
  rows = c.fetchall()
 
177
 
178
  output = BytesIO()
179
  writer = csv.writer(output)
180
+ writer.writerow(["ID", "First Name", "Last Name", "Email", "Issue", "Priority", "Date", "Generated"])
181
  writer.writerows(rows)
182
 
183
  output.seek(0)
 
193
  zip_io.seek(0)
194
  return send_file(zip_io, mimetype="application/zip", as_attachment=True, download_name="tickets.zip")
195
 
 
 
196
  if __name__ == "__main__":
197
  app.run(host="0.0.0.0", port=7860)