This is a very simple shortlink server used by 61A for links.cs61a.org (as well as a similar internal link server).
It's typically designed to work with a Google Sheet, but you can use any publicly readable CSV file.
We deploy this using Dokku, but anything that can host a simple Flask server should be fine.
- Create a workbook with at least one sheet with headers
Shortlink
,URL
, andCreator
. Anything in other columns will be ignored. Make the sheet readable to anyone with a link. - Find the workbook ID:
https://docs.google.com/spreadsheets/d/$WORKBOOK_ID/edit
. - Set the
BASE_URL
env variable tohttps://docs.google.com/spreadsheets/u/1/d/$WORKBOOK_ID/export?format=csv&id=1-$WORKBOOK_ID&gid=
. - For each sheet you want to use, find the sheet ID, which is the number after the
#
when the sheet is open. - Add all sheet IDs separated by commas to the
SHEETS
env variable.
- When using Google Sheets as described above, the document will be world readable, so avoid putting sensitive information in the links themselves.
- Links do not refresh automatically. You need to go to
yourdomain.com/_refresh
to have the server re-fetch the sheets. - All links will be at
yourdomain.com/<shortlink>
. You can see a preview of the link and the listed creator atyourdomain.com/preview/<shortlink>
.