mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-06 08:11:35 +01:00
implement contact form
This commit is contained in:
@@ -35,3 +35,15 @@ TWITCH_CHANNEL = "esports_erlangen"
|
|||||||
TWITCH_PLACEHOLDER_IMG = "placeholder.png"
|
TWITCH_PLACEHOLDER_IMG = "placeholder.png"
|
||||||
|
|
||||||
ADDITIONAL_HEADER_CONTENT = "<!-- additional content you want in <head> -->"
|
ADDITIONAL_HEADER_CONTENT = "<!-- additional content you want in <head> -->"
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
18
server.py
18
server.py
@@ -10,6 +10,7 @@ import caldav
|
|||||||
import datetime as dt
|
import datetime as dt
|
||||||
import markdown2
|
import markdown2
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
import smtplib
|
||||||
|
|
||||||
# sitemap utilities
|
# sitemap utilities
|
||||||
from werkzeug.routing import BuildError
|
from werkzeug.routing import BuildError
|
||||||
@@ -395,6 +396,23 @@ def init():
|
|||||||
else:
|
else:
|
||||||
print("Warning: Subpage Config File not found", file=sys.stderr)
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Projects Showcase',
|
parser = argparse.ArgumentParser(description='Projects Showcase',
|
||||||
|
|||||||
79
templates/contact.html
Normal file
79
templates/contact.html
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<meta name="description" content="Leauge of Legends Coaching">
|
||||||
|
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
{% include 'head.html' %}
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
{% include 'navbar.html' %}
|
||||||
|
<div class="container" style="margin-top: 4vw;">
|
||||||
|
<section class="mb-4">
|
||||||
|
<h2 class="h1-responsive font-weight-bold text-center my-4">{{ conf['CONTACT_HEADLINE'] }}
|
||||||
|
</h2>
|
||||||
|
<p class="text-center w-responsive mx-auto mb-5"> </p>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9 mb-md-0 mb-5">
|
||||||
|
<form id="contact-form" name="contact-form"
|
||||||
|
action="contact-api" method="POST" enctype='application/json'>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="md-form mb-0">
|
||||||
|
<input placeholder="{{ conf['CONTACT_PLACEHOLDER_NAME'] }}"
|
||||||
|
type="text" id="name" name="name" class="form-control">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="md-form mb-0">
|
||||||
|
<input type="text" id="email" name="email" class="form-control"
|
||||||
|
placeholder="{{ conf['CONTACT_PLACEHOLDER_EMAIL'] }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-2">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="md-form mb-0">
|
||||||
|
<input type="text" id="subject" name="subject" class="form-control"
|
||||||
|
placeholder="{{ conf['CONTACT_PLACEHOLDER_SUBJECT'] }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-2">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="md-form">
|
||||||
|
<textarea type="text" id="message" name="message" rows="2"
|
||||||
|
placeholder="{{ conf['CONTACT_PLACEHOLDER_TEXTAREA'] }}"
|
||||||
|
class="form-control md-textarea"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="text-center text-md-left mt-2">
|
||||||
|
<a class="btn btn-primary" onclick="document.getElementById('contact-form').submit();">Send</a>
|
||||||
|
</div>
|
||||||
|
<div class="status"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<div class="col-md-3 text-center">
|
||||||
|
<ul class="list-unstyled mb-0">
|
||||||
|
<li><i class="fas fa-envelope mt-4 fa-2x"></i>
|
||||||
|
<p>rejectmail@atlantishq.de</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user