summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Van Doorn <vandoorn.nick@gmail.com>2021-07-09 01:39:32 -0700
committerGitHub <noreply@github.com>2021-07-09 01:39:32 -0700
commit8cf27c07ce785c46990f24c1b0dfb9df6be675d7 (patch)
treebdb0c1b8a96e55915c984ec8c40d188d56cac1d7
Initial commit
-rw-r--r--Procfile1
-rw-r--r--app/main.py18
-rw-r--r--app/templates/home.html26
-rw-r--r--requirements.txt8
-rw-r--r--wsgi.py4
5 files changed, 57 insertions, 0 deletions
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..d06acd1
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: gunicorn wsgi:app
diff --git a/app/main.py b/app/main.py
new file mode 100644
index 0000000..9dc9b5b
--- /dev/null
+++ b/app/main.py
@@ -0,0 +1,18 @@
+from flask import *
+from tinydb import TinyDB
+
+app = Flask(__name__)
+
+@app.route("/")
+def home():
+ posts = get_db().all()
+ return render_template("home.html", posts = posts)
+
+@app.route("/message", methods=["POST"])
+def create_message():
+ form = request.form
+ get_db().insert({ "name": form["name"], "email": form["email"], "message": form["message"]})
+ return redirect("/")
+
+def get_db():
+ return TinyDB("db.json").table("messages")
diff --git a/app/templates/home.html b/app/templates/home.html
new file mode 100644
index 0000000..8820046
--- /dev/null
+++ b/app/templates/home.html
@@ -0,0 +1,26 @@
+<body style="background: purple; color: white">
+<h1>Welcome to 1337cow brother</h1>
+<form method="POST" action="/message">
+ <label>Email</label>
+ <input type="text" name="email">
+ <br>
+ <label>Name</label>
+ <input type="text" name="name">
+ <br>
+ <label>Message</label>
+ <textarea name="message"></textarea>
+ <br>
+ <input type="submit" value="Do it">
+</form>
+
+<h2>Here is what users are saying...</h2>
+{% for post in posts %}
+<strong>Name:</strong>{{ post["name"] }}
+<br>
+<strong>Email:</strong>{{ post["email"] }}
+<br>
+<strong>Message:</strong>"{{ post["message"] }}"
+<br>
+<hr>
+{% endfor %}
+</body>
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..42549db
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,8 @@
+click==8.0.1
+Flask==2.0.1
+gunicorn==20.1.0
+itsdangerous==2.0.1
+Jinja2==3.0.1
+MarkupSafe==2.0.1
+tinydb==4.5.0
+Werkzeug==2.0.1
diff --git a/wsgi.py b/wsgi.py
new file mode 100644
index 0000000..b0a20bc
--- /dev/null
+++ b/wsgi.py
@@ -0,0 +1,4 @@
+from app.main import app
+
+if __name__ == "__main__":
+ app.run()