Submit templates for repl.it/templates here.

← Back to all posts
URL Shortener Template [Python]
Irulian (7)

Here is a URL shortener that you can make your own.

Comments
hotnewtop
CodeMaster007 (108)

Wow! This is pretty cool! How does it work?

Irulian (7)

@CodeMaster007, Flask has a redirect part of it. So in the second @app.route it takes the form from the first page, which has a label that's for url. Then the slug equals the same thing but with the ending part of the form. The database (db) of slug equals the url, on the next page it gets the answer from the form and puts it into the hyperlink, and how it works is because it is linked back to the python file. Finally, the final link takes the answer from the first form and makes the link equal the url answer.

Sorry, I'm bad at explaining.
CodeMaster007 (108)

Interesting. Thats a pretty good explanation though. I didn't know that! @Irulian

Rhys07 (2)

This is incredible, how can I use this for myself? (change the domain to my own)

Irulian (7)

@RhysHelsby, You can create this your own then change the domain name in replit if you would like

Rhys07 (2)

@Irulian I can't change it, I don't know how

Irulian (7)

@RhysHelsby If you mean you don't know how to make it on your profile, just select the fork button. Sorry, I'm misunderstanding you.

Rhys07 (2)

@Irulian No your not misunderstanding, I don't know how to change the domain for the url shortener.

Irulian (7)

@RhysHelsby oh ok, you can't do it on mine though, you have to fork it then on the preview of the website there is a button that says Custom Domain. Click that, then a code will pop up, so paste that into google domains or whatever you are using.