Captive Portal - alexium/internet-filter GitHub Wiki
Development
Run pylint on the code:
pylint3 --indent-string=' ' --indent-after-paren=2 --load-plugins pylint_flask portal/*.py portal/tests/*.py
Run unit tests:
export PYTHONPATH=/home/$USER/internet-filter
./portal/tests/portal_test.py
Captive portal
You can run the captive portal in three modes:
- Test
- Development
- Production
Test
To run the captive portal in test mode, you need the following call in your unit test script:
config = ({'SQLALCHEMY_DATABASE_URI': 'sqlite:///:memory:'})
self.app = create_app(test_config=config)
Development
Set FLASK_ENV=development
in the environment.
You can run using Flask which enables automatic restart when you modify code:
cd internet-filter
FLASK_APP=portal
FLASK_ENV=development
flask run --host=0.0.0.0
Or you can run using Gunicorn:
sudo su gunicorn -c "gunicorn --workers=3 --bind 0.0.0.0:5000 'portal:create_app()'"
In both cases, the captive portal is accessed on port 5000.
Production
By default, Flask sets FLASK_ENV=production
so you only need to set this in your environment if you were previously running in development mode.
Gunicorn
Test and view logs:
sudo -u gunicorn curl --unix-socket /run/gunicorn.sock http
tail /var/log/syslog
journalctl -u gunicorn.socket