Skip to content

Python implementation of a reverse proxy for NextBus api

Notifications You must be signed in to change notification settings

Bezzi/NextBus-RP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python reverse proxy for the NextBus API

This is a python3 implementation of a reverse proxy for the NextBus API using docker-compose, allowing multiple instances of the app to run at the same time.

By creating a web server the program receives GET requests from a user and forwards it - if the request is not already cached - to the NextBus API .

Endpoints

/stats : Displays statistics of the requests stored in a Mongo database.

/?command= : Forwards GET request specified in NextBus API.

Instructions

Install "docker-compose" in the system and run the following command:

  • ./Run.sh or bash Run.sh

To create more than one instance of the app, run the following command with the adequate quantity:

  • docker-compose scale nextbus="quantity" mongodb=1 haproxy=1

Alternatively the python script "revproxy.py" could be executed locally by installing the following dependencies and python3 libraries:

Libraries:

  • http.server: To create a web server.
  • requests: For external http GET requests to NextBus API.
  • requests_cache: To store requests in cache.
  • pymongo: Driver to use Mongo database.
  • json: To return data in json format.
  • urllib: To parse query parameters.

### Python3 Dependecies:

  • redis
  • requests
  • requests_cache
  • pymongo

About

Python implementation of a reverse proxy for NextBus api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published