sohailkilledar commited on
Commit
51eaee1
·
verified ·
1 Parent(s): 22f13e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -8,44 +8,47 @@ app.secret_key = "peak_accuracy_trustify_key"
8
  UPLOAD_FOLDER = "uploads"
9
  os.makedirs(UPLOAD_FOLDER, exist_ok=True)
10
  app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
11
- app.config["MAX_CONTENT_LENGTH"] = 100 * 1024 * 1024 # 100MB Limit
12
 
13
  @app.route("/", methods=["GET", "POST"])
14
  def index():
15
  if request.method == "POST":
16
  content_type = request.form.get("type")
17
-
18
- # Text Verification Route
19
  if content_type == "text":
20
  text = request.form.get("text", "").strip()
21
  if not text:
22
  flash("Please enter some text to verify.")
23
  return redirect(url_for("index"))
24
-
25
  from services.text_checker import check_text
26
  result = check_text(text)
 
27
  return render_template("result.html", result=result)
28
 
29
- # Media Verification Route
30
  if content_type in ["image", "video"]:
31
  file = request.files.get("file")
32
  if not file or file.filename == "":
33
  flash("No file selected.")
34
  return redirect(url_for("index"))
35
-
36
  filename = f"{uuid.uuid4()}_{secure_filename(file.filename)}"
37
  path = os.path.join(app.config["UPLOAD_FOLDER"], filename)
38
  file.save(path)
39
-
40
- if content_type == "image":
41
- from services.image_checker import check_image_hybrid
42
- result = check_image_hybrid(path)
43
- else:
44
- from services.video_checker import check_video_authenticity
45
- result = check_video_authenticity(path)
46
-
 
 
 
 
47
  return render_template("result.html", result=result)
48
-
49
  return render_template("index.html")
50
 
51
  if __name__ == "__main__":
 
8
  UPLOAD_FOLDER = "uploads"
9
  os.makedirs(UPLOAD_FOLDER, exist_ok=True)
10
  app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
11
+ app.config["MAX_CONTENT_LENGTH"] = 100 * 1024 * 1024
12
 
13
  @app.route("/", methods=["GET", "POST"])
14
  def index():
15
  if request.method == "POST":
16
  content_type = request.form.get("type")
17
+
 
18
  if content_type == "text":
19
  text = request.form.get("text", "").strip()
20
  if not text:
21
  flash("Please enter some text to verify.")
22
  return redirect(url_for("index"))
23
+
24
  from services.text_checker import check_text
25
  result = check_text(text)
26
+ # Ensure your HTML file is named 'result.html' in the templates folder
27
  return render_template("result.html", result=result)
28
 
 
29
  if content_type in ["image", "video"]:
30
  file = request.files.get("file")
31
  if not file or file.filename == "":
32
  flash("No file selected.")
33
  return redirect(url_for("index"))
34
+
35
  filename = f"{uuid.uuid4()}_{secure_filename(file.filename)}"
36
  path = os.path.join(app.config["UPLOAD_FOLDER"], filename)
37
  file.save(path)
38
+
39
+ try:
40
+ if content_type == "image":
41
+ from services.image_checker import check_image_hybrid
42
+ result = check_image_hybrid(path)
43
+ else:
44
+ from services.video_checker import check_video_authenticity
45
+ result = check_video_authenticity(path)
46
+ finally:
47
+ if os.path.exists(path):
48
+ os.remove(path)
49
+
50
  return render_template("result.html", result=result)
51
+
52
  return render_template("index.html")
53
 
54
  if __name__ == "__main__":