Question and answer
- Install the required packages by running the command
pip install -r requirements.txt
in your terminal.
- Navigate to the directory containing your
main.py
file. If yourmain.py
is inside theapp
directory, you should be in the same directory as theapp
folder. - Run the command
uvicorn app.main:app --reload
in your terminal. This command tells Uvicorn to run your application, which is located in theapp.main
module, and the--reload
flag enables hot reloading, which means the server will automatically update whenever you make changes to your code.
After running the command, you should see output indicating that the server is running. You can then access the application by navigating to http://localhost:8000
in your web browser.
- Navigate to the root directory of the project (the same directory as the
app
folder). - Run the command
pytest
in your terminal.
This will discover and run all test cases in the tests
directory. Make sure you have the pytest
package installed. If not, you can install it with pip install pytest
.
- Build the Docker images by running the command
docker-compose build
in your terminal. - Start the application by running the command
docker-compose up
in your terminal.
After running these commands, you should see output indicating that the application and the MongoDB database are running. You can then access the application by navigating to http://localhost:8000
in your web browser.
To stop the application, press Ctrl+C
in your terminal. To remove the containers entirely, run docker-compose down
.