This README provides instructions for setting up and running the Flask API application on macOS using Homebrew and virtual environments.
- macOS operating system
- Homebrew installed (Installation guide)
Open Terminal and run the following command to install Python 3 using Homebrew:
brew install python
Navigate to the Flask project base directory in Terminal and create a virtual environment using the following command:
python3 -m venv venv
Activate the virtual environment by running:
``source venv/bin/activate```
While in the activated virtual environment, install the project dependencies recursively using the following command:
pip install -r requirements.txt
Activate the virtual environment by running:
python3 -m venv venv
Set your Personal Weather API Key variable from OpenWeatherMap In your terminal use the command
WEATHER_API_KEY=<actual_api_key>
Start the API using
python main.py
Open your web browser and navigate to the following URL:
http://127.0.0.1:5000/weather?lat=40.468530&long=-111.923490
You will receive a response like:
{
"Conditions": "Few Clouds",
"Temp": "Cold"
}
To run unit tests, execute the following command in Terminal:
`python test_main.py``
This will run all the unit tests and provide the test results.
Customize the port number in your main.py file if it's different from the default Flask port (5000).