Giter Site home page Giter Site logo

simpleapi's Introduction

simpleAPI

This repository is the implementation of API for create, modify, delete and update of entry in text file

Installation

  • serve.py file contains the code of the http-server.

  • .env file contains what changes need to be made initially i.e., initial setup.

  • file_store.txt contains the data.

    The .env Variables

    • IP: This field is the IP address. By default, it takes localhost as IP.
    • PORT: This field is the PORT. By default, it takes 7000 as PORT.
  • After setting up the .env file, execute serve.py by $ python3 serve.py. It will show "Server started Successfully!" on successful execution.

  • Now, Open the browser and type the API on the URL.

Requirements

The different libraries in Python3 :

  • http
  • urllib
  • re
  • decouple

Different API:

  1. http://localhost:7000/file_store.txt?action=list To list the data stored in the file_store.txt file. On success, it returns 200 and the data present in the file. If no string is present against the id, it means that there is no data.

  2. http://localhost:7000/file_store.txt?action=view&id={num} To view the data from the file where id = given num (without curly bracket). On success, it returns 200 and the data against the given id if the data is present otherwise "No Data Found!".

  3. http://localhost:7000/file_store.txt?action=delete&id={num} To delete the data from the file where id = given num (without curly bracket). On success, it returns 200 and "OK".

  4. http://localhost:7000/file_store.txt?action=create&string={string} To create the data in the file with string = given string (without curly bracket). On success, it returns 200 and "OK".

  5. http://localhost:7000/file_store.txt?action=update&id={num}&string={string} To update/edit the data present in the file with string = given string (without curly bracket) where id = given num (without curly bracket). On success, it returns 200 and "OK".

Note:

  • If no API matches, it returns 404 and "URL Not Found!".

Instruction in the file:

The Entries in the file should follow the following format:

1:string1
2:string2

simpleapi's People

Contributors

rahul-85 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.