From 26b5976fe5b074f487a98b1e9339e9217f5dce6c Mon Sep 17 00:00:00 2001 From: mediocre9 Date: Sun, 3 Nov 2024 22:57:10 +0500 Subject: [PATCH] fix #12 incorrect rendering in instruction section --- api/index.py | 7 ++++--- api/templates/index.html | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/api/index.py b/api/index.py index c7be43a..7405d1c 100644 --- a/api/index.py +++ b/api/index.py @@ -19,6 +19,7 @@ def index(): prompt = "" split_length = "" file_data = [] + num_parts = 0 redis_client.incr("visit_counter") visit_count = int(redis_client.get("visit_counter")) @@ -27,11 +28,11 @@ def index(): prompt = request.form["prompt"] split_length = int(request.form["split_length"]) - file_data = split_prompt(prompt, split_length) + file_data, num_parts = split_prompt(prompt, split_length) hash_value = generate_random_hash(8) - return render_template("index.html", prompt=prompt, split_length=split_length, file_data=file_data, hash=hash_value, visit_count=visit_count) + return render_template("index.html", prompt=prompt, split_length=split_length, num_parts=num_parts, file_data=file_data, hash=hash_value, visit_count=visit_count) def split_prompt(text, split_length): if split_length <= 0: @@ -56,7 +57,7 @@ def split_prompt(text, split_length): 'content': content }) - return file_data + return file_data, num_parts def generate_random_hash(length): return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length)) diff --git a/api/templates/index.html b/api/templates/index.html index 502a7d8..4bcc3e6 100644 --- a/api/templates/index.html +++ b/api/templates/index.html @@ -64,11 +64,11 @@

Instructions

For sending you that content, I will follow this rule: -[START PART 1/10] -this is the content of the part 1 out of 10 in total -[END PART 1/10] +[START PART 1/{{ num_parts }}] +this is the content of the part 1 out of {{ num_parts }} in total +[END PART 1/{{ num_parts }}] -Then you just answer: "Received part 1/10" +Then you just answer: "Received part 1/{{ num_parts }}" And when I tell you "ALL PARTS SENT", then you can continue processing the data and answering my requests.