diff --git a/Impressum.html b/Impressum.html deleted file mode 100644 index 03af6af..0000000 --- a/Impressum.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - Kurswerkstatt Pfarrkirchen - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- - diff --git a/backend/api.py b/backend/api.py new file mode 100644 index 0000000..11321a4 --- /dev/null +++ b/backend/api.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +""" +Very simple HTTP server in python for logging requests +Usage:: + ./server.py [] +""" +from http.server import BaseHTTPRequestHandler, HTTPServer +import json +import logging +import os +import datetime + +class S(BaseHTTPRequestHandler): + + def do_OPTIONS(self): + self.send_response(200, "ok") + # TODO remove in production + self.send_header('Access-Control-Allow-Origin', '*') + # TODO remove in production + self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS') + # TODO remove in production + self.send_header("Access-Control-Allow-Headers", "X-Requested-With") + # TODO remove in production + self.send_header("Access-Control-Allow-Headers", "Content-Type") + self.end_headers() + + def do_GET(self): + self.send_response(200) + self.send_header('Content-Type', 'application/json') + self.end_headers() + with open('schedule.json', 'r') as file: + schedule_string = json.load(file) + + self.wfile.write(json.dumps(schedule_string).encode('utf-8')) + + def do_POST(self): + + self.send_response(200, "ok") + # TODO remove in production + self.send_header('Access-Control-Allow-Origin', '*') + # TODO remove in production + self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS') + # TODO remove in production + self.send_header("Access-Control-Allow-Headers", "X-Requested-With") + # TODO remove in production + self.send_header("Access-Control-Allow-Headers", "Content-Type") + self.end_headers() + content_length = int(self.headers['Content-Length']) + request_raw = self.rfile.read(content_length) + request_content = json.loads(request_raw) + schedule = request_content['schedule'] + pw = request_content['pw'] + caption = request_content['caption'] + heading = request_content['heading'] + + if pw != '123': + self.send_response(401) + self.send_header('Content-Type', 'text/html') + self.end_headers() + self.wfile.write("Unauthorized".encode('utf-8')) + + schedule_and_caption = {} + schedule_and_caption['schedule'] = schedule + schedule_and_caption['caption'] = caption + schedule_and_caption['heading'] = heading + now = datetime.datetime.now() + try: + os.rename('schedule.json', 'schedule_{}.json'.format(now.strftime("%Y%m%d"))) + except Exception: + logging.info('Backup exists, did not backup..') + pass + with open('schedule.json', 'w') as file: + json.dump(schedule_and_caption, file) + + self.send_response(200) + self.send_header('Content-Type', 'text/html') + self.end_headers() + self.wfile.write("New schedule set".encode('utf-8')) + + +def run(server_class=HTTPServer, handler_class=S, port=8080): + logging.basicConfig(level=logging.INFO) + server_address = ('', port) + httpd = server_class(server_address, handler_class) + logging.info('Starting httpd...\n') + try: + httpd.serve_forever() + except KeyboardInterrupt: + pass + httpd.server_close() + logging.info('Stopping httpd...\n') + +if __name__ == '__main__': + from sys import argv + + if len(argv) == 2: + run(port=int(argv[1])) + else: + run() \ No newline at end of file diff --git a/backend/schedule-example.json b/backend/schedule-example.json new file mode 100644 index 0000000..da5f65e --- /dev/null +++ b/backend/schedule-example.json @@ -0,0 +1 @@ +{"schedule": {"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Joga"}, {"from": "10:30", "to": "11:45", "title": "Joga f\u00fcr Schwangere"}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{}, {}, {"from": "15:30", "to": "16:30", "title": "Musikgarten"}, {"from": "18:00", "to": "19:30", "title": "Hatha/Vinjasa Yoga"}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung"}, {"from": "10:30", "to": "11:30", "title": "Fit f\u00fcr Dich"}, {}, {}, {}, {}], "Donnerstag": [{"from": "09:00", "to": "10:00", "title": "Babymassage"}, {"from": "10:00", "to": "11:15", "title": "R\u00fcckbildung"}, {}, {}, {}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Stilltreff * 2 w\u00f6chentlich"}, {}, {"from": "16:00", "to": "19:00", "title": "Geburtsvorbereitung"}, {}, {}, {}], "Samstag": [{"from": "09:00", "to": "12:00", "title": "Geburtsvorbereitung"}, {}, {}, {}, {}, {}]}, "caption": "* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\nf\u00fcr mehr Angebote rund um Mama/Baby www.stillberatungimrottal.de"} \ No newline at end of file diff --git a/schedule.html b/schedule.html new file mode 100644 index 0000000..df36401 --- /dev/null +++ b/schedule.html @@ -0,0 +1,202 @@ + + + + + + + + + + Stundenplan Pflege + + + +
+ +
+

{{heading}}

+ + + + + + + +
{{ day }}
+
+

{{getSchuduleItem(day, slot).from}} - {{getSchuduleItem(day, slot).to}}

+

{{getSchuduleItem(day, slot).title}}

+
+
+

{{caption}}

+
+
+ + + + + + + + +
{{ day }}
+
+

-

+

+

+
Eingaben löschen +
+ +
+
+ + + diff --git a/view-schedule.html b/view-schedule.html new file mode 100644 index 0000000..a4288eb --- /dev/null +++ b/view-schedule.html @@ -0,0 +1,93 @@ + + + + + + + + Stundenplan Generator + + + +
+

{{heading}}

+ + + + + + + +
{{ day }}
+
+

{{getSchuduleItem(day, slot).from}} - {{getSchuduleItem(day, slot).to}}

+

{{getSchuduleItem(day, slot).title}}

+
+
+

{{caption}}

+
+ + +