Viewing Website Locally¶
There are four steps to viewing the website locally.
Virtualenv Setup¶
To simplify Python dependencies, use virtualenv
. This tool can be install with:
$ pip install virtualenv
Then, create a new python virtual environment for python 3.6; make sure have python 3.6 installed before run this command:
$ virtualenv -p `which python3.6` ~/<anyname>/
A virtual environment named <anyname>
will be created in home directory. To activate it:
$ source ~/<anyname>/bin/activate
The bash
prompt will now begin with (<anyname>)
. To deactivate virtualenv:
$ deactivate
Configuring Python Virtual Environment¶
Setup virtualenv and activate it. Then install requirements with
$ pip install -r requirements.txt
If you are using Ubuntu, you may get compilation errors related to psycopg2. In this case, install the needed libraries with:
$ sudo apt-get install libpq-dev python3-dev
Exporting Config vars¶
Django expects several environment variables on startup. For each required environment variable, execute
$ export <VAR_NAME>=<value>
The required environment variables are:
Name | Value |
---|---|
DJANGO_SECRET_KEY |
Give this variable a dummy value. |
GITHUB_KEY |
Retrieve this value from GitHub. |
GITHUB_SECRET |
Retrieve this value from GitHub. |
BASICAUTH_USERNAME |
Give this variable a dummy value. (you will need to enter it when accessing the local site) |
BASICAUTH_PASSWORD |
Give this variable a dummy value. (you will need to enter it when accessing the local site) |
GOOGLE_API_KEY |
Get it from team slack channel |
GOOGLE_LOGIN_KEY |
Get it from team slack channel |
GOOGLE_LOGIN_SECRET |
Get it from team slack channel |
DATABASE_URL |
Get it from team slack channel |
EMAIL_HOST |
Get it from team slack channel |
EMAIL_PORT |
Get it from team slack channel |
EMAIL_HOST_USER |
Get it from team slack channel |
EMAIL_HOST_PASSWORD |
Get it from team slack channel |
RECAPTCHA_PRIVATE_KEY |
Get it from team slack channel |
RECAPTCHA_SITE_KEY |
Get it from team slack channel |
RECAPTCHA_TEST_PRIVATE_KEY |
Get it from team slack channel |
RECAPTCHA_TEST_SITE_KEY |
Get it from team slack channel |
IS_PRODUCTION_SITE |
False |
Note
It might be helpful to add these to a file that you can run whenever you need to export them to your environment. Just remember DON’T COMMIT IT!
Note
If you want to disable basic authentication for the local site, remove BasicAuthMiddleware
from cam2webui/settings.py
.
Run Local Server¶
$ python manage.py runserver