You can create web apps with Python and Flask. This short “Hello World” tutorial shows you how to install development server for Python 3 and Flask.
There are two very successful Python web frameworks. Flask is the simple one, Django is the big one. It’s probably easier to start with Flask.
Flask is used for their API by Pintrest and Twillio. Some of the biggest sites on the Internet are built with Python, such as Youtube and Facebook. Botbook.com API one uses Flask.
Install Flask
$ sudo apt-get update $ sudo apt-get -y install python3-flask curl
Create Your Web App
$ cd $ mkdir publicFlask/ $ cd publicFlask/ $ nano main.py # ctrl-X y enter saves
Source Code for main.py
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "See you at TeroKarvinen.com!\n" if __name__ == "__main__": app.run(debug=True)
Run Development Server
$ python3 main.py # not for production * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) * Restarting with stat
Browse Your New Web App
From a different terminal (alt-ctrl-T or ugly-T for a new terminal):
$ curl http://127.0.0.1:5000/ See you at TeroKarvinen.com! $ firefox http://127.0.0.1:5000/
Well done, you’re now running a development server for Python Flask. If you edit the source files, they are reloaded automatically.
Development server is not suitable for production. For public, production install, you need Apache2 and mod_wsgi.
See also
Flask – A Python Microframework
Flask 0.10 Documentation (Ubuntu 16.04 LTS python3-flask version is 0.10)
PostgreSQL Install and One Table Database – SQL CRUD tutorial for Ubuntu
Adminstrivia: Added example use cases. Clarified language.
Yo this is dope It helped me like charm, I modified little in .conf file.
WSGIDaemonProcess run user=vagrant group=vagrant threads=5 python-path=/vagrant/app:/home/vagrant/anaconda3/envs/py/lib/python3.6/site-packages
This will be golden egg for who runing from python path error. I love anaconda set to your appropriate path.