diff --git a/cgi-bin/uebung07/doggu.html b/cgi-bin/uebung07/doggu.html new file mode 100644 index 0000000..749ff38 --- /dev/null +++ b/cgi-bin/uebung07/doggu.html @@ -0,0 +1,23 @@ + + + + + + + Indiras Fetziger Blog + + + +

Just try to think creatively

+ Tja, Pech. Nothing to see here. +
+

+

+

+ +
+ + \ No newline at end of file diff --git a/cgi-bin/uebung07/knuffig.jpg b/cgi-bin/uebung07/knuffig.jpg new file mode 100644 index 0000000..8e0dec8 Binary files /dev/null and b/cgi-bin/uebung07/knuffig.jpg differ diff --git a/cgi-bin/uebung07/posts-create.py b/cgi-bin/uebung07/posts-create.py new file mode 100644 index 0000000..debe38e --- /dev/null +++ b/cgi-bin/uebung07/posts-create.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 + +import cgi +import cgitb +cgitb.enable() + + +form = open("doggu.html", "r").read() +print("Content-type: text/html\n") +print(form) + +print('Zeig mir alle Posts!
') +print('Zeig mir alle Tags!') \ No newline at end of file diff --git a/cgi-bin/uebung07/posts-show.py b/cgi-bin/uebung07/posts-show.py new file mode 100644 index 0000000..1402b14 --- /dev/null +++ b/cgi-bin/uebung07/posts-show.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import cgi +import cgitb +import json +import os +cgitb.enable() + + +print("Content-type: text/html\n") +print("") +print("""

MEIN TOLLER BLOG

""") +file_names= [f for f in os.listdir('posts') if os.path.isfile(os.path.join('posts', f))] +file_names = sorted(file_names, reverse=True) +for lol in file_names: + lol = 'posts/' + lol + data = open(lol, "r") + data = json.load(data) + print('
') + print(str(data['title']) + '
Datum: ' + str(data['prettytime'])) + print('
') + print(str(data['content']) + '

') + for lel in data['tags']: + print('#' + str(lel) + '') + print('

') + +print() +print('Zeig mir alle Tags!
') +print('Ich will einen neuen Post bauen!') \ No newline at end of file diff --git a/cgi-bin/uebung07/posts-store.py b/cgi-bin/uebung07/posts-store.py new file mode 100644 index 0000000..e37a8dd --- /dev/null +++ b/cgi-bin/uebung07/posts-store.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 + +import cgi +import cgitb +import json +from time import strftime, time + +cgitb.enable() + +param = False + +try: + form = cgi.FieldStorage(encoding='utf8') + # nehm die Sachen aus create und bau sie in einen Post :) + title = form.getvalue('title') + content = form.getvalue('content') + tags = form.getvalue('tags')[1:].split("#") + param = True + + file_name = "posts/" + strftime("%Y-%m-%d-%H-%M-%S") + nicetime = strftime("%A, %d.%B %Y %H:%M Uhr") + file_content = { + "title": title, + "prettytime": nicetime, #das ist nicht unbedingt sinnvoll, aber mir gefällts. + "content" : content, + "tags" : tags + } + file_content = json.dumps(file_content) + f = open(file_name, "w").write(file_content) + print('Status: 303 See Other') + print('Location: posts-show.py') + print() + +except: + print("Content-type: text/html\n") + if not(param): + print("Nothing here. You reached the end of the Internet. Turn back. H.P. Backster. Hyper, Hyper.") + else: + print("Feeehhhleeeerrrr") diff --git a/cgi-bin/uebung07/posts/2019-06-14-09-52-08 b/cgi-bin/uebung07/posts/2019-06-14-09-52-08 new file mode 100644 index 0000000..2c8d54a --- /dev/null +++ b/cgi-bin/uebung07/posts/2019-06-14-09-52-08 @@ -0,0 +1 @@ +{"tags": ["intech", "sose19", "uni tuebingen"], "published": "2019-06-14-09-52-08", "title": "Intech ist super!", "content": "Inbesondere Python-CGI macht viel Spass!!!"} diff --git a/cgi-bin/uebung07/posts/2019-06-14-09-52-39 b/cgi-bin/uebung07/posts/2019-06-14-09-52-39 new file mode 100644 index 0000000..c94e336 --- /dev/null +++ b/cgi-bin/uebung07/posts/2019-06-14-09-52-39 @@ -0,0 +1 @@ +{"title": "PHP ...", "content": "... ist meine Lieblingssprache und in der naechsten Uebung fangen wir damit an!", "published": "2019-06-14-09-52-39", "tags": ["intech", "sose19", "uni tuebingen"]} diff --git a/cgi-bin/uebung07/posts/2019-06-14-09-54-27 b/cgi-bin/uebung07/posts/2019-06-14-09-54-27 new file mode 100644 index 0000000..8c6d0f3 --- /dev/null +++ b/cgi-bin/uebung07/posts/2019-06-14-09-54-27 @@ -0,0 +1 @@ +{"tags": ["klausur", "ahhhh!", "intech"], "published": "2019-06-14-09-54-27", "content": "Die Klausur findet am 22. Juli statt. Da ich die Uebungen alle bearbeitet habe, kann nichts schiefgehen!", "title": "Intech-Klausur"} diff --git a/cgi-bin/uebung07/posts/2019-06-23-19-16-45 b/cgi-bin/uebung07/posts/2019-06-23-19-16-45 new file mode 100644 index 0000000..b695945 --- /dev/null +++ b/cgi-bin/uebung07/posts/2019-06-23-19-16-45 @@ -0,0 +1 @@ +{"tags": [" kekse ", " kekese ", " ekskeks"], "published": [2019, 6, 23, 19, 16, 45, 6, 174, 1], "title": "Ih mag kekse", "content": "kesek sindd toll"} \ No newline at end of file diff --git a/cgi-bin/uebung07/tags-show.py b/cgi-bin/uebung07/tags-show.py new file mode 100644 index 0000000..8c9b7f6 --- /dev/null +++ b/cgi-bin/uebung07/tags-show.py @@ -0,0 +1,52 @@ +#!/usr/bin/python3 + +import cgi +import cgitb +import json +import os +cgitb.enable() + +tag = "" +try: + form = cgi.FieldStorage(encoding='utf8') + tag = form.getvalue('tag') +except: + pass + +# Zeug zeigen +print("Content-type: text/html\n") +print("") +print("""

ALLE TAGS

""") +file_names= [f for f in os.listdir('posts') if os.path.isfile(os.path.join('posts', f))] +tag_set = [] +if tag: + for f in file_names: + f = 'posts/' + f + data = open(f, "r") + data = json.load(data) + if tag in data['tags']: + print('
') + print(str(data['title']) + '
Datum: ' + str(data['prettytime'])) + print('
') + print(str(data['content']) + '

') + for i in data['tags']: + print('#' + str(i) + '') + print('

') +else: + print('
') + print("Tags
") + for f in file_names: + f = 'posts/' + f + data = open(f, "r") + tag_set += json.load(data)['tags'] + for i in sorted(set(tag_set)): + print('#' + str(i) + '
') + print('

') + + +print() +print('Zeig mir alle Posts!
') +print('Falls du noch nicht alle Tags siehst ist dies nach diesem Klick der Fall!
') +print('Ich will einen neuen Post bauen!')