From a2bdf2b1bf5492d88244158a0b07a8e1407f7288 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 28 Oct 2022 13:20:30 +0200 Subject: [PATCH] use specific download page, don't collect the pub key as the server --- src/public/js/download.js | 9 +++++++++ src/public/js/{main.js => index.js} | 2 +- src/routes/file.py | 8 +++----- src/templates/download.html | 31 +++++++++++++++++++++++++++++ src/templates/index.html | 2 +- 5 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 src/public/js/download.js rename src/public/js/{main.js => index.js} (98%) create mode 100644 src/templates/download.html diff --git a/src/public/js/download.js b/src/public/js/download.js new file mode 100644 index 0000000..6d5cf9b --- /dev/null +++ b/src/public/js/download.js @@ -0,0 +1,9 @@ +import { RSA_dec_data as RSA_dec } from "./rsa.js"; + +window.addEventListener("load", () => main()); + +const main = () => { + const pub_key = window.location.hash.slice(1).split(":"); + const hash = window.location.pathname.split("/").pop(); + console.log(pub_key, hash); +}; diff --git a/src/public/js/main.js b/src/public/js/index.js similarity index 98% rename from src/public/js/main.js rename to src/public/js/index.js index 55a00dd..cf34cc2 100644 --- a/src/public/js/main.js +++ b/src/public/js/index.js @@ -88,7 +88,7 @@ const send = (file, element) => { let link = `${url.join("/")}/${req.responseText.slice( 1, -2 - )}/${pub_key[0]}:${pub_key[1]}`; + )}#${pub_key[0]}:${pub_key[1]}`; let main_div = element.parentElement.parentElement; main_div.textContent = ""; diff --git a/src/routes/file.py b/src/routes/file.py index 175569c..4f7b787 100644 --- a/src/routes/file.py +++ b/src/routes/file.py @@ -4,10 +4,8 @@ from flask import Blueprint, render_template router = Blueprint("file", __name__) -@router.route("/") -def file(file_hash: int, key_data: str) -> str: +@router.route("") +def file(file_hash: int) -> str: """Download page""" print(f"hash : {file_hash}") - key = key_data.split(":") - print(f"key : {key}") - return render_template("index.html", config=Config, download=True) + return render_template("download.html", config=Config) diff --git a/src/templates/download.html b/src/templates/download.html new file mode 100644 index 0000000..0f5e07c --- /dev/null +++ b/src/templates/download.html @@ -0,0 +1,31 @@ + + + + + + + {{ config.name }} + + + + + +
+

{{ config.name }}

+
+ +
+
+

Téléchargement

+

Cliquez pour lancer le téléchargement du fichier

+ +
+
+ +
+

NPNO

+
+ + + + diff --git a/src/templates/index.html b/src/templates/index.html index b9855ee..137cf4a 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -30,6 +30,6 @@ - +