Skip to content

dg183/Icarus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 

Repository files navigation

Icarus

Basic REST API for tracking objects

Specs


Python version 3.8.5

To install all required packages: pip3 install -r requirements.txt

To run server: py main.py

To view frontend: Go to http://localhost:5000/

Routes and responses


List all spaceships

GET

http://localhost:5000/spaceship

Returns all spaceships that exist (ordered by ID) in JSON form

Code Reason/Response
200 OK

Add spaceship

POST

http://localhost:5000/spaceship

Creates a spaceship with the given information

Example payload:

{
    "name": "Shippy",
    "model": "Fast",
    "location": 1,
    "state": "Maintenance"
}
Code Reason/Response
200 OK
400 Bad request
422 Location does not exist
422 Invalid state

Update a spaceship's state

PUT

http://localhost:5000/spaceship

Update a spaceship's state to another state.

Possible states:

  • Decommissioned
  • Maintenance
  • Operational

spaceshipID must match an existing spaceship

state must match one of the possible states

Example payload:

{
    "spaceshipID": 1,
    "state": "Operational"
}
Code Reason/Response
200 OK
400 Bad request
422 Spaceship does not exist
422 Invalid state

Add location

POST

http://localhost:5000/location

Creates a location with the given information

Example payload:

{
    "city": "Sydney",
    "name": "Gas station",
    "planetName": "Earth",
    "capacity": 50
}
Code Reason/Response
200 OK
400 Bad request
422 Invalid capacity

Remove a spaceship

DEL

http://localhost:5000/spaceship

Removes a spaceship with a matching ID

Example payload:

{
    "spaceshipID": 1
}
Code Reason/Response
200 OK
400 Bad request
422 Spaceship could not be found

Remove a location

DEL

http://localhost:5000/location

Removes a location with a matching ID

Example payload:

{
    "locationID": 1
}
Code Reason/Response
200 OK
400 Bad request
422 Location could not be found

Travel

POST

http://localhost:5000/travel

Example payload:

{
    "spaceshipID": 0,
    "locationID": 1,
}
Code Reason/Response
200 OK
400 Bad request
422 Spaceship does not exist
422 Location does not exist
422 Spaceship is not operational
422 Location is at maximum capacity

Database design

Spaceship table

  • id (Primary key, INT)
  • name (VARCHAR)
  • model (VARCHAR)
  • location (Foreign key, INT) -> FK to id field in Location table
  • status (VARCHAR)

Location table

  • id (Primary key, INT)
  • city (VARCHAR)
  • name (VARCHAR)
  • planetName (VARCHAR)
  • currentCapacity (INT)
  • maxCapacity (INT)

About

Basic REST API for tracking objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published