Instavest published a blog post that shares the 3 Python libraries that are loved by startups, and this article has sparked a heated discussion among developers on Hacker news, so if you're interested in it, you might want to take a look. The author will translate this text to share to more developer friends. The translation is as follows:
1. Whitenoise
Simply modifying the config file allows the user to deploy the Web application in a static file as he or she wants, without having to rely on external services such as Nginx, Amazon S3, and so on. Whitenoise can compress packaged content and set high-capacity caches.
Applications that follow the WSGI specification require adjustments to the whitenoise configuration at deployment time:
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 this? Use gzip to effectively reduce static file volume and page loading. However, the search engine detects gzip compression, which causes the site to not perform gzip. Therefore, we need to avoid this situation through the above modification.
2. Phonenumbers (Lite version)
Identifying a phone number is not an easy task, and regular expressions do not necessarily handle a variety of valid phone formats.
For example:
- Invalid: 222-222-2222 (This will pass the regular test)
- Valid: 313-442-1231 outside the line. 901
It can be seen that relying on a single regular detection does not necessarily get the answer you want, so use the tool-phonenumbers appropriately. Recommended reason is that it is small, practical and simple, no geographical generation code, operators, time zones and other metadata data. It can recognize multiple formats and then use different formats/styles for effective matching.
3. Pdfkit
With Pdfkit, you can easily convert HTML into PDF files. What is the use of this? For example, if your app has a page with invoice information, you can use Pdfkit to help generate a PDF file for users to download, using the following:
Import pdfkitpdfkit.from_file (' test.html ', ' out.pdf ') # Generating PDFs from strings and web-pages are equally easy:pdfkit. From_string (' hello! ', ' out.pdf ') pdfkit.from_url (' http://google.com ', ' out.pdf ')
If you have your favorite Python library, you may wish to share your message with us.
3 python libraries used by start-up companies