cs50w-final-project.mov
Turn your rate-limited APIs into unlimited cached APIs through a dead-simple UI.
This is alo Aadvik's CS50w's final project!
Accquire necessary environment variables
GOOGLE_OAUTH_CALLBACK_URL = "http://localhost:8000/oauth/google/callback"
GOOGLE_OAUTH_CLIENT_ID = "your_client_id"
GOOGLE_OAUTH_CLIENT_SECRET = "your_client_secret"
To accquire these go to Google cloud console
Build the enviorment
python -m venv env
.\env\Scripts\Activate.ps1
Run the application
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
This service was built as a response to a problem I came across when using GitHub's highly rate-limited RestAPI, the solution to this would be to cache the responses which would require 18-20 fully-tested, bug-free lines of code AND a storage solution (Local, SQL); Cache it pls! tries to abstract away this process and spit out a single URL you can reliably call to your hearts content.
Unlike previous challenges of CS50 Web which were "web apps" this tries to be a useful, real-world micro-service to aid in building larger applications.
The django project comprises of 3 apps, which look like so
The site is developed using bulma along with some vanilla JavaScript to glue everything together.
core/static/core/dashboard.js
: handles the Front-End logic for/dashboard
viewcore/static/core/vendor/
: holds the static files for bulma and bulma darkly theme
At:
core/
Glues and holds the back-end logic and the UI together. It handles the following URLs
/index
/dashboard
renders a SPA-ish app that holds all logic for deleting, adding jobs. See Rest API below/logout
At:
oauth/
The OAuth is implemented for Google only, and is a singular endpoint to both login + signup user
/oauth/google
/oauth/google/callback
At:
api/
This API is responsible for controlling the client-facing actions for a cache job. The API looks like so
- Requires authentication
Example Body
{
url: "https://api.kanye.rest",
time_int: 5,
time_frame: "minutes"
}
Constraints
- The
URL
must returnapplication/json
when pinged atHEADER <url>
a 400 is returned otherwise - The
time_frame
must be one ofminutes
,hours
,days
a 400 is returned otherwise
- Requires authentication
No Body
Constraints
- If the
id
is invalid, a 404 will be returned
returns the last cached JSON field
No Body