Startups have published a blog post on Instavest, the three Python libraries that are favored by startups, this article has aroused heated discussion by developers on Hacker News. if you are also interested in this article, you may wish to take a look at it later. I will briefly translate this article to share it with more developers and friends. The translation is as follows:
1. Whitenoise
By simply modifying the Config file, you can deploy Web applications in a static file as intended without relying on external services such as Nginx and Amazon S3. Whitenoise can compress the packaged content and set a high-capacity cache.
Applications that comply with the WSGI specifications need to adjust the Whitenoise configuration during deployment:
from whitenoise import WhiteNoisefrom my_project import MyWSGIAppapplication = MyWSGIApp()application = WhiteNoise(application, root='/path/to/static/files')application.add_files('/path/to/more/static/files', prefix='more-files/')
What is the importance of doing so? Gzip can effectively reduce the volume of static files and load pages. However, the search engine detects Gzip compression, which causes the website to not execute Gzip. Therefore, we need to avoid this situation through the above modifications.
2. Phonenumbers (Lite version)
Identifying a phone number is not easy, and regular expressions may not be able to handle a wide variety of valid phone formats.
For example:
It can be seen that relying on a single regular expression detection may not be able to get the desired answer, so use the tool-Phonenumbers as appropriate. It is recommended because it is small and practical, and does not have metadata data such as geographic code, operators, and time zones. It can recognize multiple formats and then use different formats/styles for effective matching.
3. Development Kit
With the help of development kit, HTML can be easily converted into PDF files. How can this be used? For example, if your application has a page containing invoice information, you can use the development kit to generate a PDF file for users to download. its usage is as follows:
import pdfkitpdfkit.from_file('test.html', 'out.pdf')# Generating PDFs from strings and web-pages is equally easy:pdfkit.from_string('Hello!', 'out.pdf')pdfkit.from_url('http://google.com', 'out.pdf')
If you have your favorite Python library, leave a message to share with you.
The above is the details of the three Python libraries used by startups. For more information, see other related articles in the first PHP community!