项目作者: mgalvc

项目描述 :
Simple and funny application to simulate an online store
高级语言: Python
项目地址: git://github.com/mgalvc/distributed-ecommerce.git
创建时间: 2017-11-09T23:25:36Z
项目社区:https://github.com/mgalvc/distributed-ecommerce

开源协议:

下载


Ecommerce Python API - Tutorial

Please follow the steps below in order to run the Ecommerce Python API.

Setting up the environment

Before cloning this repository, please make sure that you have python3 and its pip version installed.

Then, clone the project, get into its root folder and run:

  1. pip3 install -r requirements.txt

This command will install some required libraries like Flask and GeoPy.

Server

To start a server, you must run the following command:

  1. python3 server/app.py [server_host] [server_port]

Where server_host and server_port will compose the address where the server will be listening to requests.

To enjoy all functionalities of this application, you must start at least three instances of this server.

Warehouse

To start a warehouse, you must run the following command:

  1. python3 warehouse/app.py [location] [warehouse_host] [warehouse_port]

Where location means the real warehouse’s address, e.g. Salvador, Bahia.

After that you can open http://localhost:5001/ in your browser and start playing.

Again, you can run more than one instance of this application.

Node

The node application is required to start playing with customer. It’s responsible for keeping the balance between the servers, and redirects incoming customers to different servers, according the Round Robin algorithm.

Before running a node, please open the file utils.py and change the list servers on line 3. It must contain the addresses of the servers that you just started before.

Then you can run the following command to start a node:

  1. python3 node/app.py [node_host] [node_port]

You don’t need more than one running instance of node.

Customer

To start a customer you must run the following command:

  1. python3 customer/app.py [location] [node_host] [node_port]

After that you can open http://localhost:5000/ in your browser and start playing.

Run more than one instance of customer and have fun.