Shortlinks¶
Handler for go.cs61a.org and links.cs61a.org shortlinks.
Local Development¶
Create and activate a venv:
$ python3 -m venv env
$ source env/bin/activate
Use pip
to install all the dependencies:
$ pip install -r requirements.txt
Run the server:
$ python main.py
Code Documentation¶
-
class
shortlinks.main.
AccessRestriction
(value)[source]¶ Enumeration of access restrictions: all (0), staff (1), student (2).
-
shortlinks.main.
add_url_params
(url, params_string)[source]¶ Takes in a URL and a string of parameters, and adds the parameters to the URL.
-
shortlinks.main.
lookup
(path)[source]¶ Looks up a path in the database.
- Parameters
path – path to look up
- Returns
result of lookup, or
(None, None, None)
upon failure.
Returns authorization status based on the given access restriction.
- Parameters
secure (AccessRestriction) – access restriction
- Returns
authorization status (
True
orFalse
)