Merge pull request #1 from rzmk/demo
This commit is contained in:
commit
1f27ae09c8
2 changed files with 19 additions and 2 deletions
21
README.md
21
README.md
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<h3 align="center">fridges-api</h3>
|
||||
<div align="center">
|
||||
<a href="#"><strong>Try this server using Binder! »</strong></a>
|
||||
<a href="https://mybinder.org/v2/gh/rzmk/fridges-api/HEAD"><strong>Try this API using Binder! »</strong></a>
|
||||
<br />
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -20,9 +20,26 @@ Built from the Backend (**Rest APIs and FLASK**) Workshop by [@lucentfong](https
|
|||
|
||||

|
||||
|
||||
## Demoing the Server and Requests
|
||||
|
||||
1. **Setup your files.** You can follow along with an online environment using [binder]("https://mybinder.org/v2/gh/rzmk/fridges-api/HEAD") or locally by cloning/forking/downloading this repository.
|
||||
2. **Build a new virtual environment.** Open a terminal (For binder: _File > New > Terminal_) and use commands like `virtualenv venv --python=python3` or `python -m venv venv` (may be `python3` for unix). You should see a `venv` folder generated.
|
||||
3. **Activate your virtual environment.** On Windows I use `source venv\\Scripts\\activate`, another option is `source venv/bin/activate` (use this one on binder). You should see `(venv)` before your terminal prompt once activated successfully.
|
||||
4. **Install required dependencies.** You can simply use `pip install -r requirements.txt` (may be `pip3` for unix). If you want to do so manually instead, do `pip install flask` for the API and `pip install requests` for the API requests script.
|
||||
5. **Run the flask server.** You can do this by running the command `flask run`.
|
||||
6. **Run api_test.py.** Open another terminal and run `python api_test.py` (may be `python3` for unix).
|
||||
|
||||
You should be able to see the requests run with outputs on both terminals! 🎉
|
||||
|
||||
Here is a demo going through all the steps on [binder](https://mybinder.org/v2/gh/rzmk/fridges-api/HEAD):
|
||||
|
||||

|
||||
|
||||
Feel free to change values within `app.py` and `api_test.py`.
|
||||
|
||||
## File Details
|
||||
|
||||
- `api.py` - Flask API server, can be ran with command `flask run`.
|
||||
- `app.py` - Flask API server, can be ran with command `flask run`.
|
||||
- `api_test.py` - Various HTTP requests using the `requests` module to test the local flask server endpoints. You can also instead use [Postman](https://www.postman.com/) or [Thunder Client on VSCode](https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client).
|
||||
- `requirements.txt` - can be used with command `pip install -r requirements.txt` to install all virtual environment dependencies (run this command _after activating your virtual environment_). You can instead solely install `flask` for the server.
|
||||
|
||||
|
|
|
|||
BIN
binder_demo.gif
Normal file
BIN
binder_demo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 MiB |
Loading…
Add table
Add a link
Reference in a new issue