3 Python libraries used by startups

巴扎黑
Release: 2017-03-29 15:53:26
Original
1425 people have browsed it

A blog post was published on Instavest. The article shared three Python libraries that are popular among startups. The article triggered heated discussions among developers on Hacker News. If you are also interested in this, you may wish to read it. . The author has briefly translated this article to share it with more developer friends. The translation is as follows:

1. Whitenoise

By simply modifying the Config file, users can deploy web applications as static files according to their own intentions without having to rely on external services such as Nginx and Amazon S3. Whitenoise can compress packaged content and set up high-capacity caching.

Applications that follow the WSGI specification need to adjust the Whitenoise configuration during deployment:

from whitenoise import WhiteNoise

from my_project import MyWSGIApp

application = MyWSGIApp()
application = WhiteNoise(application, root='/path/to/static/files')
application.add_files('/path/to/more/static/files', prefix='more-files/')
Copy after login

What is the importance of doing this? Using Gzip can effectively reduce static file size and page loading. However, search engines will detect Gzip compression, which will cause the website not to implement Gzip. Therefore, this situation needs to be avoided through the above modifications.

2. Phonenumbers (lite version)

It is not easy to identify phone numbers, and regular expressions may not be able to handle the wide variety of valid phone formats.

For example:

  • Invalid: 222-222-2222 (this will pass the regex test)

  • Valid: 313-442-1231 Outside. 901

It can be seen that relying on a single regularity detection may not necessarily lead to the desired answer, so it is necessary to make appropriate use of the tool-Phonenumbers. The reason for recommendation is that it is compact, practical and simple, and does not have metadata such as geographical codes, operators, time zones, etc. It recognizes multiple formats and then uses different formats/styles for efficient matching.

 3. Pdfkit

With the help of Pdfkit, you can easily convert HTML into PDF files. What is the use of this? For example, if your application has a page containing invoice information, you can use Pdfkit to help generate a PDF file for users to download. The usage is as follows:

import pdfkit

pdfkit.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')
Copy after login

If you have a Python library you like, please leave a message to share it with everyone.

The above is the detailed content of 3 Python libraries used by startups. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!