diff --git a/example_config.py b/example_config.py index 0b18287..f932234 100644 --- a/example_config.py +++ b/example_config.py @@ -35,3 +35,15 @@ TWITCH_CHANNEL = "esports_erlangen" TWITCH_PLACEHOLDER_IMG = "placeholder.png" ADDITIONAL_HEADER_CONTENT = "" + +CONTACT_HEADLINE="Contact Us" + +CONTACT_PLACEHOLDER_NAME="Your Name" +CONTACT_PLACEHOLDER_EMAIL="Your Email" +CONTACT_PLACEHOLDER_SUBJECT="Subject" +CONTACT_PLACEHOLDER_TEXTAREA="Your Message" + +TARGET_SMTP=None +TARGET_EMAIL=None +TARGET_SMTP_USER=None +TARGET_SMTP_AUTH=None diff --git a/server.py b/server.py index da41c38..64132a9 100755 --- a/server.py +++ b/server.py @@ -10,6 +10,7 @@ import caldav import datetime as dt import markdown2 import PIL.Image +import smtplib # sitemap utilities from werkzeug.routing import BuildError @@ -395,6 +396,23 @@ def init(): else: print("Warning: Subpage Config File not found", file=sys.stderr) +@app.route("/contact") +def contact(): + return flask.render_template("contact.html", conf=app.config) + +@app.route("/contact-api", methods=['POST']) +def contactAPI(): + + email = flask.request.form["email"] + name = flask.request.form["name"] + subject = "Subject: {} ({})\n\n".format(flask.request.form["subject"], name) + message = subject + flask.request.form["message"] + smtpTarget = smtplib.SMTP(app.config["TARGET_SMTP"]) + smtpTarget.sendmail(email, app.config["TARGET_EMAIL"] , message) + smtpTarget.quit() + + return flask.redirect("/thanks") + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Projects Showcase', diff --git a/templates/contact.html b/templates/contact.html new file mode 100644 index 0000000..d98d2d7 --- /dev/null +++ b/templates/contact.html @@ -0,0 +1,79 @@ + + + + + + + + + + {% include 'head.html' %} + + + + + {% include 'navbar.html' %} +
+
+

{{ conf['CONTACT_HEADLINE'] }} +

+

+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+ Send +
+
+
+ + +
+ +
+
+ +