install python3.6 and Flask

reffer

http://python.zombie-hunting-club.com/entry/2017/11/03/223503

install python 3.6

[root@centos6 ~]# yum install https://centos6.iuscommunity.org/ius-release.rpm

===============================================================
パッケージ アーキテクチャ
バージョン リポジトリー 容量
===============================================================
インストールしています:
ius-release noarch 1.0-15.ius.centos6 /ius-release 8.5 k

トランザクションの要約
===============================================================
インストール 1 パッケージ

合計容量: 8.5 k
インストール済み容量: 8.5 k
[root@centos6 ~]# yum install python36u python36-libs python36u-devel python36u-pip

==============================================================================================================================
パッケージ アーキテクチャ バージョン リポジトリー 容量
==============================================================================================================================
インストールしています:
python36u x86_64 3.6.5-1.ius.centos6 ius 55 k
python36u-devel x86_64 3.6.5-1.ius.centos6 ius 917 k
python36u-pip noarch 9.0.1-1.ius.centos6 ius 1.8 M
依存性関連でのインストールをします。:
python36u-libs x86_64 3.6.5-1.ius.centos6 ius 9.0 M
python36u-setuptools noarch 39.0.1-1.ius.centos6 ius 774 k

トランザクションの要約
==============================================================================================================================
インストール 5 パッケージ

総ダウンロード容量: 12 M
インストール済み容量: 54 M

[root@centos6 ~]# python3.6 -V
Python 3.6.5
[root@centos6 ~]# which python3.6
/usr/bin/python3.6

install flask

[root@centos6 ~]# pip3.6 install Flask

-- skip

You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

[root@centos6 ~]# pip3.6 install --upgrade pip

Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
100% |????????????????????????????????| 1.3MB 335kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-18.0

[root@centos6 ~]# pip3.6 install Flask
Requirement already satisfied: Flask in /usr/lib/python3.6/site-packages (1.0.2)
Requirement already satisfied: click>=5.1 in /usr/lib/python3.6/site-packages (from Flask) (6.7)
Requirement already satisfied: Jinja2>=2.10 in /usr/lib/python3.6/site-packages (from Flask) (2.10)
Requirement already satisfied: Werkzeug>=0.14 in /usr/lib/python3.6/site-packages (from Flask) (0.14.1)
Requirement already satisfied: itsdangerous>=0.24 in /usr/lib/python3.6/site-packages (from Flask) (0.24)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib64/python3.6/site-packages (from Jinja2>=2.10->Flask) (1.0)

test web server and browser access

[root@centos6 flask]# vi server.py
[root@centos6 flask]# cat server.py
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
return 'Hello'

if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=80)

[root@centos6 flask]# python3.6 server.py
* Serving Flask app "server" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 276-308-652

-- access by browser
192.168.11.5 - - [05/Aug/2018 08:54:05] "GET / HTTP/1.1" 200 -
192.168.11.5 - - [05/Aug/2018 08:54:05] "GET /favicon.ico HTTP/1.1" 404 -
[root@centos6 templates]# ^C

test original html

[root@centos6 flask]# mkdir __pycache__
[root@centos6 flask]# mkdir templates
[root@centos6 flask]# vi templates/index.html
[root@centos6 flask]# cat templates/index.html
<!-- index.html -->
<!DOCTYPE html>
<html lang="ja">
  <head>
  </head>
  <body>
    <h1>hello from index.html</h1>
  </body>
</html>
[root@centos6 flask]# cat server.py
# server.py
from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':
    app.debug = True
    app.run(host='0.0.0.0', port=80)
[root@centos6 flask]# python3.6 server.py
 * Serving Flask app "server" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 276-308-652
192.168.11.5 - - [05/Aug/2018 12:05:14] "GET / HTTP/1.1" 200 -
^C