API implementation using Flask, currently hosted here. Check out the examples.
We have one file with the name books.csv. The CSV file contains the general information about the books, like book name, author, year of publication, etc. Develop two API endpoints, where you can see the requirements below:
- API will return number of rows requested from the books.csv file.
- Input : rows=3
- Output: (JSON)
- 2nd API will give freedom to the user to filter and see any data from the file. The user could
only able to filter from the given column list. If a column is not present then a graceful error
message should return. Even if the API didn’t find any filter response then the user should
get a empty response.
- Input: Ex. (JSON) {"authors":"Jesse Grant"}
- Output: (JSON)
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
You will need these software for this project to install.
git
python3
Follow these steps to get the server running:
First, clone this project using git.
git clone https://github.com/mohitsahoo/api-pydev.git
Then, cd into the directory and install the required libraries using pip.
cd api-pydev/
python3 -m pip install -r requirements.txt
Then run it using:
python run.py
You can run the unit tests using the tests.py
file.
To run it simply go to your terminal in the project directory and type this and enter:
python tests.py
For deployment, we have to move from the default server to a production server. More info on deployment instructions here.
For development purposes, you can deploy it using the following command:
sudo flask run --host=0.0.0.0 --port=80
- Flask - The web framework used
- Flask RESTFul - REST API Management
- Mohit Sahoo - Initial work - (website)
This project is unlicensed you're free to copy, modify, publish, use, compile, sell, or distribute this software - see the LICENSE.md file for details.