Yup, but you’d still need a database since you need to store that lookup somewhere from long URL to short url.
Here's the website[1] I built with base64 encoding to share weblinks. I've been trying to think of a non-db approach, but haven't found one yet for link shortening.