This is a short guide on setting up the system and environment dependencies required for the mflix application to run.
Once you've installed Python 3, you will have to setup a
virtualenv
environment:
# navigate to the mflix-python directory
cd mflix-python
# create the virtual environment for MFlix
python -m venv .venv
# activate the virtual environment
source .venv/bin/activate
You can deactivate the virtual environment with the following command:
deactivate
Please remember that you may have to reactivate the virtual environment if you open a new Terminal or Command Prompt window, or restart your system.
Once the Python 3 environment is activated, we need to install our python
dependencies. These dependencies are defined in the requirements/dev.txt
file,
and can be installed with the following command:
pip install -r requirements/dev.txt
pip install -r requirements/test.txt
It is recommended to connect mflix with MongoDB Atlas, so you do not need to have a MongoDB server running on your host machine. Refer to setup Atlas domentation.
But there is docker-compose
file to set mongodb locally:
docker-compose up -d
This will set mongo on local port 27017
.
That said, you are still required to have the MongoDB server installed, in order to be able to use two server tool dependencies:
-
mongorestore
- A utility for importing binary data into MongoDB.
-
mongo
- The MongoDB shell
To start mflix, run the following command:
python run.py
And then point your browser to http://localhost:5000.
To run migrations you need to setup FLASK_APP
variable and run flask command:
export FLASK_APP=run.py
flask migrate
To run the unit tests for this course, you will use pytest
. Each course lab
contains a module of unit tests that you can call individually with a command
like the following:
pytest -m LAB_UNIT_TEST_NAME
Each ticket will contain the command to run that ticket's specific unit tests.