Flask is a lightweight web service program, which is simple, easy to use, and flexible. It is mainly used for some API services here.
1. Related Links
- GitHub:https://github.com/pallets/flask
- Official documentation: http://flask.pocoo.org
- Chinese documentation: http://docs.jinkan.org/docs/flask
- PyPI:https://pypi.python.org/pypi/Flask
2. pip install
It is recommended to use pip to install, the command is as follows:
pip3 install flask
After running, the installation is complete.
3. Verify the installation
After the installation is successful, you can run the following sample code to test:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
It can be found that the system will open the web service on port 5000, and the console output is as follows:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Directly visit http://127.0.0.1:5000/ , you can observe that Hello World! is displayed in the web page, as shown in Figure 1-41, the simplest Flask program runs successfully.
Figure 1-41 Running result
4. Conclusion
Later, we will use Flask+Redis to maintain the dynamic proxy pool and Cookies pool.