From c2d46da747c4901c7fd7821c0fde715dd6bbf3a1 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Wed, 12 Mar 2025 08:07:18 -0600 Subject: Working on tv corner --- cgi-bin/submit_blahaj_info.cgi | 114 ----------------------------------------- 1 file changed, 114 deletions(-) delete mode 100755 cgi-bin/submit_blahaj_info.cgi (limited to 'cgi-bin/submit_blahaj_info.cgi') diff --git a/cgi-bin/submit_blahaj_info.cgi b/cgi-bin/submit_blahaj_info.cgi deleted file mode 100755 index 4c2e1b6..0000000 --- a/cgi-bin/submit_blahaj_info.cgi +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python - -import cgi -import json -import datetime - -# Get the information given and dump it into a file. -def handle_fields(): - form = cgi.FieldStorage() - - blahaj_name = form.getvalue("blahaj_name") - blahaj_info = form.getvalue("blahaj_info") - - if blahaj_name == None: - return "Blahaj name is required" - - if blahaj_info == None: - blahaj_info = "" - - blahaj_list = [] - - # Get existing data. - try: - with open("blahaj_info.json", "r") as fp: - blahaj_list = json.load(fp) - except FileNotFoundError: - pass - - date = datetime.datetime.now() - blahaj_entry = {"name": blahaj_name, "info": blahaj_info, "date": date.strftime("%B, %d %Y")} - - # Already been added. - for blahaj in blahaj_list: - if blahaj["name"] == blahaj_entry["name"] and blahaj["info"] == blahaj_entry["info"]: - return "Already exists" - - # Dump new data. - with open("blahaj_info.json", "w") as fp: - blahaj_list.append(blahaj_entry) - json.dump(blahaj_list, fp) - - return "submitted" - -def display_context(fields_reponse): - print('Content-Type: text/html') - - html_text = """ - - - - - hehehe - - - - - -
- - - - -
- thing_to_replace -
-
- - - - """ - - # Place html tags in the "thing_to_replace" spot - replace_text = "" - - if fields_reponse == "Blahaj name is required": - replace_text = """ -

Blahaj name required

-

Go back

- """ - elif fields_reponse == "Already exists": - replace_text = """ -

Blahaj already added

-

Go back

- """ - elif fields_reponse == "submitted": - replace_text = """ -

Blahaj submitted!

- yippee! -

See it in the list!

- """ - - html_text = html_text.replace("thing_to_replace", replace_text) - - print(html_text) - - -fields_reponse = handle_fields() -display_context(fields_reponse) -- cgit v1.2.3