diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 3297de4..3ae8447 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,11 +1,19 @@ +<<<<<<< HEAD sqlite.xerial true org.sqlite.JDBC jdbc:sqlite:C:\Users\mohah\Desktop\Zappster\database.db +======= + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/database.db +>>>>>>> ff4241330bf771777f8c00ae0d86802851513bd8 $ProjectFileDir$ diff --git a/flask_app.py b/flask_app.py index 3a9bbe5..9f53fc2 100644 --- a/flask_app.py +++ b/flask_app.py @@ -1,9 +1,9 @@ import secrets import sqlite3 import string +from pathlib import Path import requests -import os from flask import Flask, jsonify, request, render_template app = Flask(__name__) @@ -11,7 +11,7 @@ def generate_uid(db_id): alphabet = string.ascii_lowercase + string.digits - return f"{db_id}-" + ''.join(secrets.choice(alphabet) for _ in range(4)) + return f"{db_id}-" + ''.join(secrets.choice(alphabet) for _ in range(8)) def dict_factory(cursor, row): @@ -27,7 +27,6 @@ def db_connect(): cursor = connection.cursor() return cursor, connection - @app.route('/') def home(): cur, conn = db_connect() @@ -52,19 +51,25 @@ def list_cards(): @app.route('/wish/') def wish_form(card_id): cur, conn = db_connect() - card = cur.execute(f'SELECT * FROM card WHERE cardid={card_id};').fetchone() + card = cur.execute("SELECT * FROM card WHERE cardid=?", (card_id,)).fetchone() conn.close() return render_template("send_wish.html", card=card) -def send_mail(email, sender, cardid, uid): +def send_mail(email, sender,receiver, cardid, uid): + card_img = f"http://zappsters.pythonanywhere.com/static/{cardid}.jpg" + banner_img = f"http://zappsters.pythonanywhere.com/static/mail_banner.jpeg" + logo_img = f"http://zappsters.pythonanywhere.com/static/logo_mail.png" + git_img = f"http://zappsters.pythonanywhere.com/static/git.png" + x = requests.post("https://api.mailgun.net/v3/sandboxa39931aba4ea43a885c240d815b0a2c2.mailgun.org/messages", auth=("api", "9374b99615d0f43ff1e12995ef3c3317-8d821f0c-6df1ae28"), - files=[('inline[0]', ('card.jpg', open(f'{os.getcwd()}/static/{cardid}.jpg', mode='rb').read()))], + files=[('inline[0]', ('card.jpg', open(Path.cwd() / f'static/{cardid}.jpg', mode='rb').read()))], data={"from": "laurens@zappsters.pythonanywhere.com", "to": [f"{email}"], "subject": "Greeting card", - "text": f"You have been sent an AR greeting card from {sender}! The unique code for your personnel message i: " + uid}) + "html": render_template("mail.html", sender=sender, code=uid, receiver=receiver, + card=card_img, banner=banner_img, logo=logo_img, git=git_img)}) return x.text @@ -89,11 +94,12 @@ def wish_insert(): uid = generate_uid(db_id) if send_method == "email": - send_mail(send_destination,sender,card_id, uid) + send_mail(send_destination, sender,receiver, card_id, uid) - card = cur.execute('SELECT * FROM card WHERE cardid' + '=' + str(card_id) + ';').fetchone() + card = cur.execute("SELECT * FROM card WHERE cardid=?", (card_id,)).fetchone() + print(card) conn.execute( - f"INSERT INTO wish (uid, sender, message, cardid) VALUES (\'{uid}\', \'{sender}\', \'{message}\', {card_id})") + "INSERT INTO wish (uid, sender, message, cardid) VALUES (?,?,?,?)", (uid, sender, message, card_id)) conn.commit() conn.close() return render_template("confirm_wish.html", card=card) @@ -108,7 +114,7 @@ def get_wish(): def result_wish(): uid = request.form.get("uuid") cur, conn = db_connect() - personal_card = cur.execute(f"SELECT * FROM wish WHERE uid=\'{uid}\';").fetchone() + personal_card = cur.execute("SELECT * FROM wish WHERE uid=?", (uid,)).fetchone() conn.close() return render_template("show_wish.html", card=personal_card) @@ -124,11 +130,11 @@ def get_personal_wish(): # connect and open the database file database.db cur, conn = db_connect() # read the associated personal wish, you will need an extra integer field code in your wish table! - wish = cur.execute(f"SELECT * FROM wish WHERE code={code}").fetchall() + wish = cur.execute("SELECT * FROM wish WHERE code=?", (code,)).fetchall() conn.close() # there's only one wish because the code is unique response = jsonify(wish[0]) # allow cross-domain Ajax requests, more info in later years response.headers.add("Access-Control-Allow-Origin", "*") - return response + return response \ No newline at end of file diff --git a/static/git.png b/static/git.png new file mode 100644 index 0000000..1c53810 Binary files /dev/null and b/static/git.png differ diff --git a/static/logo_mail.png b/static/logo_mail.png new file mode 100644 index 0000000..106726d Binary files /dev/null and b/static/logo_mail.png differ diff --git a/static/mail_banner.jpeg b/static/mail_banner.jpeg new file mode 100644 index 0000000..fac27cd Binary files /dev/null and b/static/mail_banner.jpeg differ diff --git a/templates/about.html b/templates/about.html index 1e73bdf..9627f86 100644 --- a/templates/about.html +++ b/templates/about.html @@ -4,25 +4,32 @@ {% block content %}

Over ons

-
-
- matthias -
- Matthias Theys
Ik ben Matthias, 19 jaar en vindt het leuk om mij bezig te houden met auto's en en Netwerken. -
-
-
-
-
- Mohammed -
- Mohammed Hamioui
Ik ben Mohammed, 19 jaar en heb passie voor technologie en cyber security. Verantwoordelijk voor de business kaart layout en het front-end gedeelte van de website.
-
-
-
+
+
+ matthias +
+ Matthias Theys
Ik ben Matthias, 19 jaar en vindt het leuk om mij + bezig te houden met auto's en en Netwerken. +
+
+
+
+
+ Mohammed +
+ Mohammed Hamioui
Ik ben Mohammed, 19 jaar en heb passie voor + technologie en cyber security. Verantwoordelijk voor de business kaart layout en het front-end + gedeelte van de website
+
+
+
+>>>>>>> ff4241330bf771777f8c00ae0d86802851513bd8 -
+
+<<<<<<< HEAD
Laurens @@ -42,4 +49,28 @@

Over ons

+======= +
+
+ Laurens +
+ Laurens Karakolev
+ Ik ben Laurens, 19 jaar oud en ga volgend jaar waarschijnlijk App & AI verderstuderen. +
+
+
+
+
+ kaïs +
+ kaïs Boutaleb
+ Ik ben kaïs, 21 jaar en fan van alles waar technologie in zit. Ik ben zeer geïnteresseerd in + cybersecurity en AI. maar ook andere zaken buiten IT zoals talen en muziek. Hier ben ik + verantwoordelijk voor de backend van de website +
+
+
+ +>>>>>>> ff4241330bf771777f8c00ae0d86802851513bd8 {% endblock %} diff --git a/templates/mail.html b/templates/mail.html new file mode 100644 index 0000000..9c2f432 --- /dev/null +++ b/templates/mail.html @@ -0,0 +1,498 @@ + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+ + + + + + + +
+ + + + + + + +
+   +
+ +
+ + + + + + + + +
+
+
+
+
+ + +
+
+
+
+
+ + + + + + + + +
+
+
+
+
+ + +
+
+
+
+
+ + + + + + +
+ + + + + +
+ + Banner + +
+ +
+ + + + + + + + + + + + + + + +
+ + + + + +
+ + Banner + +
+ +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + + + + +
+ + +
+
+
+
+
+ + + + + + +
+ + + +
+
+
+
+
+
+ + +
+
+
+
+
+ + + + + + +
+ +

+ Vragen?
mail@zappsters.com +

+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ +
+
+ + + + + + +
+ + Github + +
+ +
+
+ +
+ + + + + + + +
+ +
+

©2022 Zappsters | Thomas more Geel +

+
+ +
+
+
+
+
+
+
+ + + diff --git a/templates/send_wish.html b/templates/send_wish.html index 7457020..9be7b1d 100644 --- a/templates/send_wish.html +++ b/templates/send_wish.html @@ -16,6 +16,7 @@

Stuur uw boodschap

+
@@ -26,6 +27,7 @@

Stuur uw boodschap

@@ -57,6 +59,7 @@

Stuur uw boodschap

+