Skip to content

juancho20sp/final-ayed-backend

Repository files navigation

Backend AYED

What is this?

This is a repository for all the files used to create a backend with flask in order to connect our functions with a simple JavaScript web application. This project was deployed to Heroku and the URL is: https://obscure-sierra-80708.herokuapp.com/.

Getting Started

For implementing this library you will need to have Python installed in your computer.

Prerequisites

To use this library you will need to have Python installed in your computer, at least the version 3.7.
You can check your Python version typing on cmd:

python --version

Installing

  • Clone this git repository into your computer.
  • Start coding!
# In your root folder:

git clone https://github.com/juancho20sp/final-ayed-backend.git

Using the Virtual Environment

Activate:

cd venv/Scripts
activate

Deactivate:

cd venv/Scripts
deactivate

Install requirements:

  • With the venv activated:
pip install -r requirements.txt

API

PUT REQUESTS

  • /graph : Here you will find the functionallity based on the BFS algorythm for graphs. The JSON structure of a PUT request to this endpoint should look like this:
{
    // Start node for BFS
    "start": 0,
    
    // Goal node for BFS
    "goal": 4,
    
    // List of edges (from-to)
    "edges": "0-1,0-2,0-3,3-4"
}
  • The server response for /graph will be a JSON with this structure:
{
    // The distance (node count) between 'start' and 'goal'
    "distance": 2,
    
    // The path from 'start' to 'goal'
    "nodes": [2, 4]
}
  • /priority_queue: Here you will find the functionallity based on a priority queue and a binary heap. The JSON structure of a PUT request to this endpoint should look like this:
{
    // The name of each person
    "names": "Melissa,Juan,Ernesto,Andres,Javier,Vanessa,Mariana,Pedro,Luz",
    
    // The popularity of each person
    "popularity": "90,87,10,24,37,65,70,14,93",
    
    // The number of times this person have spoken with our goal.
    "times_spoken": "15,30,5,1,55,19,25,173,47"
    
    // Note that the data is ordered by index, so popularity[0] and times_spoken[0] correspond to names[0]
}
  • The server response for /priority_queue will be a JSON with this structure:
{
    // An array with the data of the mos important people in the list
    data: [{'name': 'Luz', 'score': 4371}, {'name': 'Juan', 'score': 2610}, {'name': 'Pedro', 'score': 2422}]
}
  • /sets: Here you will find the functionallity based on disjoint sets. The JSON structure of a PUT request to this endpoint should look like this:
{
    // The list of known nodes
    "nodes": "0,1,2,3,4,5,6,7,8,9",
    
    // List of connections between nodes (from-to)
    "edges": "0-1,0-2,1-2,4-5,4-6,5-6,7-8,7-9,8-9,11-12,11-13,14-14"
}
  • The server response for /sets will be a JSON with this structure:
{    
    // List of related regions (each related region is an array)
    "related_regions": [1, [2,3,4], [5,6,7,8,9]]
}
  • /djikstra: Here you will find the functionallity based on the Djikstra algorythm. The JSON structure of a PUT request to this endpoint should look like this:
{
    // Start node for Djikstra's algorythm
    "start": 0,
    
    // Goal node form Djikstra's algorythm
    "goal": 4,
    
    // List of connections (from-to-cost)
    "edges": "0-1-16,0-2-2,0-3-1,1-4-1,2-4-0,3-4-3"
}
  • The server response for /djikstra will be a JSON with this structure:
{
    // Array with the order in which nodes should be visited
    "route": [1,3,5,6],
    
    // Cost of 'route'
    "cost": 11
}

Built With

  • Python 3.8 - As the main programming language and Flask as microframework.

Author

License

This is an open source project.

Thanks for checking out!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages