Added examples
This commit is contained in:
26
uebung7/uebung07-examples/tasks-store.py
Normal file
26
uebung7/uebung07-examples/tasks-store.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/python3
|
||||
# coding=utf-8
|
||||
|
||||
import cgi
|
||||
|
||||
from tasks_lib import enc_print
|
||||
from tasks_lib import create_task, write_task, redirect, print_exception_page
|
||||
|
||||
try:
|
||||
# Zugriff auf Formulardaten
|
||||
form = cgi.FieldStorage(encoding='utf8')
|
||||
title = form.getfirst('title')
|
||||
|
||||
assert title is not None
|
||||
|
||||
# Task erstellen und speichern
|
||||
task = create_task(title)
|
||||
write_task(task["timestamp"], task)
|
||||
|
||||
# Weiterleitung auf Übersichtsseite
|
||||
redirect("tasks-show.py")
|
||||
|
||||
|
||||
# Rudimentäres Error-Handling ...
|
||||
except Exception as e:
|
||||
print_exception_page("Fehler", "Fehler beim Hinzufügen!", e)
|
Reference in New Issue
Block a user