diff --git a/backend/api.py b/backend/api.py index 11321a4..85a5b51 100644 --- a/backend/api.py +++ b/backend/api.py @@ -9,42 +9,24 @@ import json import logging import os import datetime +import base64 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: + with open('data/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) @@ -52,8 +34,9 @@ class S(BaseHTTPRequestHandler): pw = request_content['pw'] caption = request_content['caption'] heading = request_content['heading'] + image = request_content['image'] - if pw != '123': + if pw != 'kurswerk': self.send_response(401) self.send_header('Content-Type', 'text/html') self.end_headers() @@ -65,13 +48,16 @@ class S(BaseHTTPRequestHandler): schedule_and_caption['heading'] = heading now = datetime.datetime.now() try: - os.rename('schedule.json', 'schedule_{}.json'.format(now.strftime("%Y%m%d"))) + os.rename('data/schedule.json', 'data/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: + with open('data/schedule.json', 'w') as file: json.dump(schedule_and_caption, file) + with open('data/schedule.jpg', 'wb') as f: + f.write(base64.b64decode(image)) + self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() @@ -96,4 +82,4 @@ if __name__ == '__main__': if len(argv) == 2: run(port=int(argv[1])) else: - run() \ No newline at end of file + run() diff --git a/backend/nginx.conf b/backend/nginx.conf new file mode 100644 index 0000000..df3bb9b --- /dev/null +++ b/backend/nginx.conf @@ -0,0 +1,58 @@ + +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + disable_symlinks off; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + upstream backend { + server kurswerkstatt-pan_backend:8080; + } + + server { + root /usr/share/nginx/html; + + location /api/ { + proxy_read_timeout 300s; + proxy_connect_timeout 75s; + proxy_redirect off; + proxy_http_version 1.1; + proxy_pass http://backend; + proxy_set_header Host $host ; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + try_files $uri $uri/ /index.html; + } + } + + include /etc/nginx/conf.d/*.conf; + +} diff --git a/data/schedule.jpg b/data/schedule.jpg new file mode 100644 index 0000000..d09c961 Binary files /dev/null and b/data/schedule.jpg differ diff --git a/data/schedule.json b/data/schedule.json new file mode 100644 index 0000000..0501d72 --- /dev/null +++ b/data/schedule.json @@ -0,0 +1 @@ +{"schedule": {"Montag": [{"from": "09:00", "to": "10:00", "title": "Pilates #"}, {}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{"from": "09:00", "to": "10:00", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {"from": "10:15", "to": "11:30", "title": "R\u00fcckbildung\n(mit Julia)"}, {}, {}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:00", "title": "Babymassage\n(mit Julia)"}, {}, {}, {}, {"from": "17:30", "to": "18:30", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {}], "Donnerstag": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung \n(mit Julia)"}, {}, {}, {}, {"from": "18:15", "to": "19:45", "title": "Progressive \nMuskelentspannung \n(n. Jacobsen) \""}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Still-\n und Elterntreff *\n(1x im Monat)"}, {}, {}, {}, {}, {}], "Samstag": [{}, {}, {}, {}, {}, {}]}, "caption": "# mit Physiotherapeutin Timea Sobotta\n\" mit Physiotherapeutin Felicitas Sch\u00f6nberger\n* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\n", "heading": "Stundenplan 2020"} \ No newline at end of file diff --git a/data/schedule_20191120.json b/data/schedule_20191120.json new file mode 100644 index 0000000..e759857 --- /dev/null +++ b/data/schedule_20191120.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", "heading": "Stundenplan 2019"} \ No newline at end of file diff --git a/data/schedule_20191121.json b/data/schedule_20191121.json new file mode 100644 index 0000000..e759857 --- /dev/null +++ b/data/schedule_20191121.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", "heading": "Stundenplan 2019"} \ No newline at end of file diff --git a/data/schedule_20191122.json b/data/schedule_20191122.json new file mode 100644 index 0000000..a2f4d81 --- /dev/null +++ b/data/schedule_20191122.json @@ -0,0 +1 @@ +{"schedule": {"Montag": [{"from": "09:00", "to": "10:15", "title": "Hatha Yoga"}, {"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", "heading": "Stundenplan 2019"} \ No newline at end of file diff --git a/data/schedule_20200308.json b/data/schedule_20200308.json new file mode 100644 index 0000000..0501d72 --- /dev/null +++ b/data/schedule_20200308.json @@ -0,0 +1 @@ +{"schedule": {"Montag": [{"from": "09:00", "to": "10:00", "title": "Pilates #"}, {}, {}, {"title": ""}, {"from": "", "to": "", "title": ""}, {}], "Dienstag": [{"from": "09:00", "to": "10:00", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {"from": "10:15", "to": "11:30", "title": "R\u00fcckbildung\n(mit Julia)"}, {}, {}, {}, {}], "Mittwoch": [{"from": "09:00", "to": "10:00", "title": "Babymassage\n(mit Julia)"}, {}, {}, {}, {"from": "17:30", "to": "18:30", "title": "Fit f\u00fcr Dich\n(mit Julia)"}, {}], "Donnerstag": [{"from": "09:00", "to": "10:15", "title": "R\u00fcckbildung \n(mit Julia)"}, {}, {}, {}, {"from": "18:15", "to": "19:45", "title": "Progressive \nMuskelentspannung \n(n. Jacobsen) \""}, {}], "Freitag": [{"from": "09:00", "to": "10:30", "title": "Still-\n und Elterntreff *\n(1x im Monat)"}, {}, {}, {}, {}, {}], "Samstag": [{}, {}, {}, {}, {}, {}]}, "caption": "# mit Physiotherapeutin Timea Sobotta\n\" mit Physiotherapeutin Felicitas Sch\u00f6nberger\n* mit Stillberaterin und Kinderkrankenschwester Rhianon Grill\n", "heading": "Stundenplan 2020"} \ No newline at end of file diff --git a/index.html b/index.html index 09f1887..200cfc8 100644 --- a/index.html +++ b/index.html @@ -196,7 +196,8 @@
+
+