diff --git a/tests/test_main.py b/app/__init__.py
similarity index 100%
rename from tests/test_main.py
rename to app/__init__.py
diff --git a/app/app.py b/app/app.py
new file mode 100644
index 0000000..b34e9e5
--- /dev/null
+++ b/app/app.py
@@ -0,0 +1,21 @@
+#!/usr/local/bin/python3
+
+from flask import Flask, render_template, request
+from app.send_page import send_page
+
+
+app = Flask(__name__)
+
+@app.route("/", methods=['GET'])
+def index():
+ return render_template('index.html', status='')
+
+@app.route("/", methods=['POST'])
+def send():
+ result = send_page(
+ name=request.form.get('name'),
+ email=request.form.get('email'),
+ message=request.form.get('message')
+ )
+ status = 'success' if result[0] else 'fail'
+ return render_template('index.html', status=status)
diff --git a/app/main.py b/app/main.py
index a6053f8..3596682 100644
--- a/app/main.py
+++ b/app/main.py
@@ -1,7 +1,10 @@
#!/usr/local/bin/python3
+from app.app import app
+
+
def main():
- # Commands here
+ app.run()
if __name__ == "__main__":
diff --git a/app/send_page.py b/app/send_page.py
new file mode 100644
index 0000000..2d6beaf
--- /dev/null
+++ b/app/send_page.py
@@ -0,0 +1,31 @@
+#!/usr/local/bin/python3
+
+import os
+import requests
+
+
+def send_page(name: str, email: str, message: str) -> tuple:
+ api_url = "https://api.pushover.net/1/messages.json"
+ api_token = os.getenv('PUSHOVER_API_TOKEN')
+ user_key = os.getenv('PUSHOVER_USER_KEY')
+
+ full_msg = f"Name: {name}\nEmail: {email}\n\nMessage: {message}"
+
+ payload = {
+ 'token': api_token,
+ 'user': user_key,
+ 'title': f"ePage from {name}",
+ 'message': full_msg,
+ 'priority': "1",
+ 'sound': 'cosmic'
+ }
+
+ req = requests.post(
+ api_url,
+ json=payload,
+ headers={'Content-Type': 'application/json'}
+ )
+
+ if req.status_code == 200 and req.json().get('status') == 1:
+ return (True, None)
+ return (False, req.json())
diff --git a/app/static/msg.png b/app/static/msg.png
new file mode 100644
index 0000000..c39147f
Binary files /dev/null and b/app/static/msg.png differ
diff --git a/app/templates/index.html b/app/templates/index.html
new file mode 100644
index 0000000..90057e6
--- /dev/null
+++ b/app/templates/index.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+ ePage
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% if status == 'success' %}
+ Message sent!
+ {% elif status == 'fail' %}
+ We could not send your message. Please try again.
+ {% endif %}
+
+
+
+
+
+
+
diff --git a/requirements.txt b/requirements.txt
index e69de29..f84c801 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -0,0 +1,11 @@
+certifi==2022.6.15
+charset-normalizer==2.1.0
+click==8.1.3
+Flask==2.1.2
+idna==3.3
+itsdangerous==2.1.2
+Jinja2==3.1.2
+MarkupSafe==2.1.1
+requests==2.28.1
+urllib3==1.26.10
+Werkzeug==2.1.2
diff --git a/sonar-project.properties b/sonar-project.properties
index 286b4f0..217bc47 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,8 +1,9 @@
-sonar.projectKey=luketainton_
+sonar.projectKey=luketainton_epage_AYHpcqLKSbMjdyWLhHix
sonar.python.version=3.10
sonar.python.coverage.reportPaths=coverage.xml
sonar.python.pylint.reportPaths=lintreport.txt
sonar.python.xunit.reportPath=testresults.xml
sonar.sources=app
sonar.tests=tests
-sonar.exclusions=,.github/**,.gitignore,CODEOWNERS,CHANGELOG.md,LICENSE.md,README.md,renovate.json,requirements-dev.txt,requirements.txt
\ No newline at end of file
+sonar.exclusions=.github/**,.gitignore,CODEOWNERS,CHANGELOG.md,LICENSE.md,README.md,renovate.json,requirements-dev.txt,requirements.txt
+sonar.coverage.exclusions=app/main.py
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..7daa129
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python3
+
+import pytest
+
+from app.app import app
+
+
+@pytest.fixture
+def client():
+ client = app.test_client()
+ yield client
diff --git a/tests/test_app.py b/tests/test_app.py
new file mode 100644
index 0000000..62c0155
--- /dev/null
+++ b/tests/test_app.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+
+import pytest
+
+from tests import client
+
+
+def test_index(client) -> None:
+ req = client.get('/')
+ assert req.status_code == 200 and "ePage" in req.text
diff --git a/tests/test_send_page.py b/tests/test_send_page.py
new file mode 100644
index 0000000..c34b17b
--- /dev/null
+++ b/tests/test_send_page.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+from app.send_page import send_page
+
+
+def test_send_page_no_env() -> None:
+ result = send_page(
+ name='Unit Test',
+ email='none@none.com',
+ message='Unit Test'
+ )
+ assert result[0] == False and result[1].get('token') == 'invalid'