Code Monkey home page Code Monkey logo

sheets-url-shortener's Introduction

URL Shortener with a Google Spreadsheet πŸ“‘

This is a simple web server that can redirect a pre-defined set of URLs in Google Sheets. All you need to do is define a Google Sheets like the following, and deploy a simple app just by clicking around.

shortcut url
gh https://github.com/ahmetb
yt https://www.youtube.com/watch?v=dQw4w9WgXcQ
cv https://docs.google.com/document/d/1c97PrqTFqiMpannv2/edit
resume /cv

Costs: This can be deployed to Google Cloud Run and run for free thanks to generous free tier (+Google Sheets is free with a Gmail account as well).

This redirector also supports path additions on top of base URLs, for example, with the sheet row:

shortcut url
gcp https://github.com/GoogleCloudPlatform

The go.ahmet.dev/gcp/golang-samples will be redirected to https://github.com/GoogleCloudPlatform/golang-samples.

Setup

  1. Create a new Google Sheet: https://sheets.new.

  2. Add two columns, first column is the "shortcut", the second column is the "url" to redirect the user. (see example)

  3. Save the ID of your Sheet from the URL (it’s a random string that looks like 1SMeoyesCaGHRlYdGj9VyqD-qhXtab1jrcgHZ0irvNDs).

  4. Click to deploy to Cloud Run, and provide your spreadsheet ID while deploying:

    Run on Google Cloud

  5. Go to https://console.cloud.google.com/run, click on sheets-url-shortener service. Find the email address written in the "Service Account" section.

  6. Go to your Google Sheets, click "Share" and give this email address "Viewer" access on your sheet.

  7. Go to https://console.developers.google.com/apis/api/sheets.googleapis.com/overview and make sure the Google Sheets API is enabled.

  8. (Optional) If you want to use a custom domain like go.ahmet.dev, go to https://console.cloud.google.com/run/domains and map the sheets-url-shortener to your custom domain!

Advanced Configuration

This server can be configured with these following parameters:

Environment Variable Description
SHEET_NAME (optional) If you have multiple sheets in a spreadsheet, specify the sheet name.
CACHE_TTL (optional) how frequently the spreadsheet must be reloaded (default: 5s)
HOME_REDIRECT (optional) which url to redirect when root url (/) is visited
LISTEN_ADDR (optional) which network address to listen on (default "" which means all interfaces)
PORT (optional) http port to listen on (default 8080).

Disclaimer

This is not an official Google project. It's distributed as-is under Apache 2.0 License. See LICENSE.

sheets-url-shortener's People

Contributors

ahmetb avatar lgruen avatar steren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sheets-url-shortener's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.