Python flask offline Installation and testing

Source: Internet
Author: User

Flask is a common Python web framework when using Python for web development.
If the server can be connected to the external network, you can simply use the PIP install Flask directly to the Flask dependency package and Flask directly installed.
But the company's test environment, usually intranet, can not be connected with the table on the external network, which requires the use of offline package installation.
Here is my test installation process.

1. Identify the dependent packages (ref.: Http://stackoverflow.com/questions/18951829/how-to-install-flask-offline):

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 this order before you install Flask.

Well, that's Werkzeug, jinja2,markupsafe,babel,pytz,itsdangerous, these few. Flask's documentation only mentions that it relies on Werkzeug and JINJA2, but installing JINJA2 offline will result in an error, so it needs to be all.

2. Download the package in a dedicated download: Https://pypi.python.org/pypi, of course, use the search box in the upper right corner.
You may see a lot, you can choose the XXXXX.tar.gz version, some packages are not necessarily comprehensive, but also need search engines, they may be on GitHub.

3. For a dependency package, you can also view install_requires content in the setup.py of the extracted directory after an installation package
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 ',
],
These four dependent packages need to be installed to install flask properly, and these four dependent packages also have other dependencies:
The dependent packages required for jinja2-2.9.6 installation are:
install_requires=[' markupsafe>=0.23 '),

Werkzeug-0.12.1 installation does not require a dependent package;

ITSDANGEROUS-0.24 installation does not require a dependent package;

click-6.7 installation does not require a dependent package;

MarkupSafe-1.0 installation does not require a dependent package;


4. Download and decompress the following content, and then install it in the order of software dependencies
[email protected] flask]# LL
Total 2472
Drwxr-xr-x 4096 May 16:25 click-6.7
-rw-r--r--1 root root 279019 may 16:21 click-6.7.tar.gz
Drwxr-xr-x users 4096 May 16:30 Flask-0.12.1
-rw-r--r--1 root root 548511 may 16:15 flask-0.12.1.tar.gz
Drwxr-xr-x 6 503 4096 may 16:26 itsdangerous-0.24
-rw-r--r--1 root root 46541 may 16:21 itsdangerous-0.24.tar.gz
Drwxr-xr-x 501 4096 may 16:28 jinja2-2.9.6
-rw-r--r--1 root root 437659 may 16:19 jinja2-2.9.6.tar.gz
Drwxr-xr-x 6 501 4096 may 16:29 MarkupSafe-1.0
-rw-r--r--1 root root 14356 may 16:28 markupsafe-1.0.tar.gz
Drwxr-xr-x users 4096 May 16:27 Werkzeug-0.12.1
-rw-r--r--1 root root 1169595 may 16:19 werkzeug-0.12.1.tar.gz

Unzip all the packages in turn, and then execute the install command:
TAR-ZXVF *.tar.gz
Cd
Python setup.py Install
PIP List

After all packages have been installed, confirm the flask status:
# PIP List | grep Flask
Flask (0.12.1)


5. After the Flask installation is complete, test the application to write and access:

Start with a minimal 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)

Startup script:
Python hello.py

Open your browser and visit "Http://127.0.0.1:9000/" to see the familiar "Hello world! The


Note: All of the above packages, which I have uploaded, can be downloaded directly using.

Python flask offline Installation and testing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.