Enter a URL to call an API and see its response!
Sample API (Enter this into the box at the top once you successfully run the app!): https://swapi.dev/api/planets/1/
Ensure that you have Python installed. If you do not, see here to download it.
-
Clone this repository
Using HTTPS:
git clone https://github.com/IanWearsHat/hacknights-w-2024-template-flask.git
or SSH (you would need to set up an SSH key. See here for more information, otherwise use HTTPS):
git clone git@github.com:IanWearsHat/hacknights-w-2024-template-flask.git
-
Create a virtual environment
This isolates the libraries you install in this environment from the libraries on your actual machine, preventing conflicts between libraries.
python3 -m venv .venv
-
Activate virtual environment
VS Code may prompt to automatically select the newly created virtual environment. Otherwise, for Mac/Linux, run
source .venv/bin/activateand for Windows, run
.\.venv\scripts\activate
-
Install dependencies
pip install -r requirements.txt
This will install all of the packages that you need for the python files to work.
Run this command:
flask runand a server will run at http://127.0.0.1:5000 (or http://localhost:5000).
Note: changing any Python code will not update the server that is running. You must stop the server and re-run flask run to see any changes.
However, if you run
flask run --debugFlask will automatically reload itself if you change the Python code. This also enables an interactive debugger.