This repository contains code for Coursework 2 of the COMP3011 Web Services & Web Data module.
https://sc20osc.pythonanywhere.com/
admin
{
"username": "admin",
"password": "admin",
}
ammar
{
"username": "ammar",
"password": "ammar",
}
To use the service as an admin, you may access the admin functions using https://sc20osc.pythonanywhere.com/admin/ using the provided admin credentials. This will allow you to access and modify the database. Note that this will automatically make the changes on other impacted services also.
Below are some useful commands that can be used to run the service locally.
# Install dependencies
pip install -r requirements.txt
# Run migrations
python manage.py makemigrations api
python manage.py migrate
# Populate database
python manage.py populate_database
# Create admin
python manage.py create_admin
# Run server
python manage.py runserver
# Run tests
python manage.py runtests # Locally only
# Backup database
python manage.py backup_database
The full database schema can be found, as generated by Swagger (see the Schemas section).
The full API list can also be found, as generated by Redoc and by Swagger.
To use the service with its API functionality, see generated documentation by Redoc or by Swagger for information on each endpoint including its method, request and response formats. The provided endpoints are;
- https://sc20osc.pythonanywhere.com/api/flights/ (this supports GET, PUT, PATCH and DELETE)
- https://sc20osc.pythonanywhere.com/api/bookings/ (this supports GET, PUT, PATCH and DELETE)
- https://sc20osc.pythonanywhere.com/api/airlines/ (this supports GET only)
- https://sc20osc.pythonanywhere.com/api/airports/ (this supports GET only)
- https://sc20osc.pythonanywhere.com/api/cities/ (this supports GET only)
- https://sc20osc.pythonanywhere.com/api/countries/ (this supports GET only)
Users can filter flights based on query parameters. For example:
/api/flights/?departure_airport=US-5875&destination_airport=LUCL
/api/flights/?airline=AA&base_price_min=100&base_price_max=300
/api/flights/?departure_datetime_min=2023-05-15T21:47:23Z&departure_datetime_max=2023-06-15T00:00:00Z
The filters allow users to search for flights within a range of values for various parameters such as departure datetime, arrival datetime, duration time, base price, total seats, and available seats. Users can also filter by departure airport, destination airport, and airline.
Users can filter airports based on query parameters. For example:
/api/airports/?city=Amboy
/api/airports/?country=US
/api/airports/?region=US-NY
/api/airports/?type=large_airport
/api/airports/?latitude_min=40&latitude_max=45
/api/airports/?longitude_min=-80&longitude_max=-70
/api/airports/?elevation_min=100&elevation_max=200
/api/airports/?continent=NA
Note that the filtering is case-insensitive and uses the icontains lookup expression for text-based fields, which means it will match any airport containing the specified text. You can change the lookup expression to suit your needs.
- Airlines (e.g. using
?code=AA
) - Bookings (e.g. using
?booking_ref=NRZDW7I4KP&passport_number=123&flight=123
) - Cities (e.g. using
?name=New York&country=US
) - Countries (e.g. using
?name=US&continent=NA
)
See the views.py
file for more information on the filters used.
Below are some other diagrams that were created during the development of this service. They have been created using PyCharm's built-in diagramming tool.