Flask (Lightweight Python web framework) on mint

 

$ sudo apt search python-pip
p   python-pip                      - alternative Python package installer      
idA python-pip-whl                  - alternative Python package installer
$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Recommended packages:
  build-essential python-all-dev python-wheel
The following NEW packages will be installed:
  python-pip
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 0 B/144 kB of archives.
After this operation, 635 kB of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 647024 files and directories currently installed.)
Preparing to unpack .../python-pip_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip (8.1.1-2ubuntu0.4) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-pip (8.1.1-2ubuntu0.4) ...
$ sudo apt show python-pip
Package: python-pip
Version: 8.1.1-2ubuntu0.4
Priority: optional
Section: universe/python
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 635 kB
Depends: ca-certificates, python-pip-whl (= 8.1.1-2ubuntu0.4), python:any (<< 2.8), python:any (>= 2.7.5-5~)
Recommends: build-essential, python-all-dev (>= 2.6), python-setuptools, python-wheel
Homepage: https://pip.pypa.io/en/stable/
Download-Size: 144 kB
APT-Manual-Installed: yes
APT-Sources: http://ubuntu-mirror.totbb.net/ubuntu xenial-updates/universe amd64 Packages
Description: alternative Python package installer
 pip is a replacement for easy_install, and is intended to be an improved
 Python package installer.  It integrates with virtualenv, doesn't do partial
 installs, can save package state for replaying, can install from non-egg
 sources, and can install from version control repositories.

N: There is 1 additional record. Please use the '-a' switch to see it
$ sudo pip install Flask
The directory '/home/nano/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/nano/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting Flask
  Downloading Flask-0.12.1-py2.py3-none-any.whl (82kB)
    100% |████████████████████████████████| 92kB 691kB/s 
Requirement already satisfied: itsdangerous>=0.21 in /usr/lib/python2.7/dist-packages (from Flask)
Collecting click>=2.0 (from Flask)
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 3.6MB/s 
Requirement already satisfied: Werkzeug>=0.7 in /usr/lib/python2.7/dist-packages (from Flask)
Requirement already satisfied: Jinja2>=2.4 in /usr/lib/python2.7/dist-packages (from Flask)
Requirement already satisfied: MarkupSafe in /usr/lib/python2.7/dist-packages (from Jinja2>=2.4->Flask)
Installing collected packages: click, Flask
Successfully installed Flask-0.12.1 click-6.7
$ nano hello.py


#!/usr/bin/python

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello Nano!"

if __name__ == "__main__":
    app.run('0.0.0.0')


$ chmod +x hello.py
$ ./hello.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
$ curl http://localhost:5000
Hello Nano!

Screenshot at 2017-04-25 12-21-17

 

http://www.w3ii.com/th/flask/flask_quick_guide.html

https://jahchaisang.gitbooks.io/fra142-gui/content/chapter2-0.html

Advertisements

About NanoSoftTech

NanoSoftTech
This entry was posted in Framework, Language, Linux Mint. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s