In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to install and test python Flask offline. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.
Flask is a common Python web framework for web development in Python.
If the server can connect to the external network, you can simply install Flask's dependency package and Flask directly with pip install Flask.
However, the company's test environment, generally intranet, can not be connected to the external network with the table, which requires offline software package installation.
Below is my test installation process.
1. Identify dependent packages:
You need to download all of flask's dependencies:'
Werkzeug>=0.7
Jinja2>=2.4, which requires:
MarkupSafe
Babel>=0.8, which requires:
pytz
itsdangerous>=0.21
Install them in that order before you install Flask.
Um, Werkzeug, Jinja2, MarkupSafe, Babel, pytz, itsdangerous, these few. Flask's documentation only mentions that it depends on Werkzeug and Jinja2, but installing Jinja2 offline will give an error, so it needs all of them.
2. Download packages in the special download area: https://pypi.python.org/pypi, of course, using the search box in the upper right corner.
You may see a lot, you can choose XXXXX.tar.gz version, some packages are not necessarily comprehensive, but also need search engines, they may be on github.
3. For dependency packages, you can also download an installation package and view the install_requirements content in setup.py of the decompression directory.
Flask-0.12.1 The packages required for offline installation are:
install_requires=[
'Werkzeug>=0.7',
'Jinja2>=2.4',
'itsdangerous>=0.21',
'click>=2.0',
],
All four dependencies need to be installed before Flask can be installed properly; these four dependencies also have other dependencies:
Jinja2-2.9.6 requires:
install_requires=['MarkupSafe>=0.23'],
Werkzeug-0.12.1 installation has no required dependencies;
itsdangerous-0.24 Installation has no required dependencies;
click-6.7 Installation has no required dependencies;
MarkupSafe-1.0 installation has no required dependencies;
4. After downloading and decompressing the following contents, install them in order of software dependency
[root@tk-dat-asa202 Flask]# ll
total 2472
drwxr-xr-x 10 1000 1000 4096 May 15 16:25 click-6.7
-rw-r--r-- 1 root root 279019 May 15 16:21 click-6.7.tar.gz
drwxr-xr-x 10 1000 users 4096 May 15 16:30 Flask-0.12.1
-rw-r--r-- 1 root root 548511 May 15 16:15 Flask-0.12.1.tar.gz
drwxr-xr-x 6 503 20 4096 May 15 16:26 itsdangerous-0.24
-rw-r--r-- 1 root root 46541 May 15 16:21 itsdangerous-0.24.tar.gz
drwxr-xr-x 10 501 20 4096 May 15 16:28 Jinja2-2.9.6
-rw-r--r-- 1 root root 437659 May 15 16:19 Jinja2-2.9.6.tar.gz
drwxr-xr-x 6 501 20 4096 May 15 16:29 MarkupSafe-1.0
-rw-r--r-- 1 root root 14356 May 15 16:28 MarkupSafe-1.0.tar.gz
drwxr-xr-x 10 1000 users 4096 May 15 16:27 Werkzeug-0.12.1
-rw-r--r-- 1 root root 1169595 May 15 16:19 Werkzeug-0.12.1.tar.gz
Unzip all the packages in turn, and then execute the installation command:
tar -zxvf *.tar.gz
cd
python setup.py install
pip list
After all packages are installed, confirm Flask status:
# pip list | grep Flask
Flask (0.12.1)
5. After Flask is installed, test application writing and access:
Start with the smallest application:
vim hello.py
The script reads as follows:
#/usr/bin/env python
#_*_ coding:utf-8 _*_
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World! '
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9000)
Start script:
python hello.py
Open your browser and visit http://127.0.0.1:9000/ to see the familiar "hello world! "Yes. About "python Flask how to install and test offline" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.