prepare download endpoint

This commit is contained in:
Mylloon 2022-10-28 01:04:49 +02:00
parent 63394435a5
commit 421e72d3a3
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 18 additions and 2 deletions

View file

@ -4,11 +4,13 @@ from werkzeug.wrappers.response import Response
from config import init
from routes.api.download import router as api_download
from routes.api.upload import router as api_upload
from routes.file import router as download
from routes.index import router as index
app = Flask(__name__, static_url_path="/", static_folder="public")
app.register_blueprint(index, url_prefix="/index")
app.register_blueprint(api_upload, url_prefix="/api/upload")
app.register_blueprint(download, url_prefix="/file")
app.register_blueprint(api_download, url_prefix="/api/download")
init()

View file

@ -4,8 +4,9 @@ from werkzeug.wrappers.response import Response
router = Blueprint("download", __name__)
@router.route("", methods=["POST"])
def download() -> Response:
@router.route("<file_hash>", methods=["POST"])
def download(file_hash: str) -> Response:
"""Download interface"""
# TODO: Send the encrypted file to the javascript client
print("download of file", file_hash)
return redirect("index")

13
src/routes/file.py Normal file
View file

@ -0,0 +1,13 @@
from config import Config
from flask import Blueprint, render_template
router = Blueprint("file", __name__)
@router.route("<int:file_hash>/<string:key_data>")
def file(file_hash: int, key_data: str) -> 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)