diff --git a/main.py b/main.py index 26167a6..97b19fd 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,35 @@ -from flask import Flask +from flask import Flask, make_response, render_template, request, redirect, url_for +from markupsafe import escape app = Flask(__name__) @app.route('/') -def index(): - return "This is an example app" \ No newline at end of file +@app.route('/') +def index(username = None): + return render_template("index.html", name = username) + +@app.route('/contact') +def contact(): + return "

Book your first consultation:

Epasts: example@example.com

" + +@app.route('/login', methods=['GET', 'POST']) +def login(): + if request.method == 'POST': + username = request.form['username'] + return redirect(url_for('index', username=escape(username))) + return render_template("form.html") + + +import unittest + +class TestStringMethods(unittest.TestCase): + def test_upper(self): + client = app.test_client() + response = client.post("/login", data = {'username': "Test"}) + response = client.get(response.location) + self.assertEqual(response.status_code, 200) + self.assertIn("Test", response.text) + + +if __name__ == '__main__': + unittest.main()