moxw / api-pydev

API implementation using Flask

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api-pydev

API implementation using Flask, currently hosted here. Check out the examples.

Problem Statment

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:

  1. API will return number of rows requested from the books.csv file.
    • Input : rows=3
    • Output: (JSON)

Result

Screenshot_2021-04-04_20:30:38:520

  1. 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)

Result

Screenshot_2021-04-04_20:32:20:704

Getting Started

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.

Prerequisites

You will need these software for this project to install.

git
python3

Installing

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

Running the tests

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

Deployment

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

Built With

Authors

License

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.

About

API implementation using Flask

License:The Unlicense


Languages

Language:Python 100.0%