如何创建URL缩短程序(使用python),而无需大量导入或其他内容 [英] How to create a URL shortner (with python) without importing bittly or other stuff
问题描述
因此,我最近开始对不使用任何痛苦或其他事情的情况下如何创建URL缩短程序感兴趣,但是我不太擅长使用python与其他内容进行连接.我所知道的是:
So I recently became interested into knowing how to create a URL shortener without using bittly or other things, but I am not very good at using python to connect with other stuff. All I know is:
- 检查URL是否可用(仅查看URL是否具有HTTP://和不可用的字符,看不到该域是否被占用.)
所有其他...我需要帮助.
All of the other things... I need help with.
顺便说一句,我完全不知道该怎么做,因此,如果您添加注释以显示正在发生的事情,那就太好了.
By the way, I COMPLETLY do not understand how to do that, so it would be great if you add comments to show me what is going on.
推荐答案
我建议您看一下Flask,它是用于构建Web应用程序(API,Web应用程序等)的框架.
I suggest you take a look at Flask, it is a framework for building web applications (APIs, web apps, etc.).
DigitalOcean具有很好的教程.
DigitalOcean has a nice tutorial on this.
您可以对自定义的缩短的URL使用哈希算法,甚至可以让用户选择更具可读性的名称(例如bit.ly/my-url).在这种情况下,您将把缩短的URL和长的URL存储在数据库中.
You can either use hashing algorithms for the custom shortened urls, or even let the user pick more readable names (like bit.ly/my-url). In this case you would be storing in a database the shortened url and the long url.
这篇关于如何创建URL缩短程序(使用python),而无需大量导入或其他内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!