Repo for CS9163 Assignment 02
This website is developed with Flask, Python3, and Bootstrap.
Register, login into the website, and submit text for spell-checking.
-
Install requirements with pip
pip install -r requirements.txt
-
To test the service with unittest, execute the script in ./tests/myunittest.py
python ./tests/myunittest.py
-
To start this Flask application
chmod +x app.py ./app.py
or with Flask command (tested in Ubuntu VM):
cd src/ export FLASK_APP=app.py flask run
- Open the browser and enter URL http://127.0.0.1:5000/cs9163/hw02/
- The URLs available are:
- home: http://127.0.0.1:5000/cs9163/hw02/ ← redirect to login page
- login: http://127.0.0.1:5000/cs9163/hw02/login
- register: http://127.0.0.1:5000/cs9163/hw02/register
- spell check: http://127.0.0.1:5000/cs9163/hw02/spell_check ← require user login
This assignment project has switched from pytest to unittest.
One of the most important reasons for this is that, by using pytest, it is difficult to perform testing along with CSRF protection, provided by flask_wtf.
Besides, when using unittest, app.config["WTF_CSRF_ENABLED"] = False
can successfully turn off CSRF protection in order to simply check whether these routes are reachable. But this config setting doesn't work when using pytest.
In brief, testcases in this project only perform without CSRF protection and only check whether the requests and responses are successfully sent and received.
Some of the source codes are learnt from this Flask project Tutorial Youtube Video.