Before you start, you need to have Python 3 installed on your machine. You can check if you have Python 3 installed by running the following command in your terminal:
python3 --versionIf Python 3 is not installed, you can download it from the official website: https://www.python.org/downloads/
To create a virtual environment, follow these steps:
-
Open your terminal and navigate to the directory where you want to create your virtual environment.
-
Run the following command to create a virtual environment named venv:
python3 -m venv venv- Activate the virtual environment by running the following command:
source venv/bin/activateYou should now see '(venv)' at the beginning of your command prompt, indicating that you are in the virtual environment.
Once you have activated your virtual environment, you can install the required packages for the project by running the following command in your terminal:
pip3 install -r requirements.txtOnce you have created your virtual environment and installed Flask, you can run the Flask application by running the following command in the temrinal:
flask runThe Flask application should now be running on http://localhost:5000/. You can access it using a REST client. For debug mode, just add --debug to the command above.
You can perform requests to the endpoints on this project by accessing them through any REST client, in this case a insomnia.json file is provided with sample requests.
Make sure you have Insomnia installed, if not you can download it from the official website: https://insomnia.rest/download
Then, import the insomnia.json file into Insomnia, this will load a collection of requests called YouGov Challenge, click on the collection and you will find four requests
- Get question - ✅: Given a variable ID, get the associated question's data, including lable, uuid, options and more.
- Get answer count - ✅: Given a variable ID, get the answer count to the associated question.
- Get question - ❌: Returns an error given the invalid variable ID
- Get answer count - ❌: Returns an error given the invalid variable ID
- This app in NOT production-ready.
- This app provides a minimal viable solution to the challenge described in the
Instructions.txtfile, following the recommendations under theGuidancesection. Major architectural and implementation desicions (e.g. project structure, error handling, modularization, unit testing, end-to-end testing, etc) were explicitly left out in favor of a simpler solution to the challenge provided. - This app is provided under de MIT License.