Install Flask is very easy and there shouldn't be any troubles with it if you will do the next steps:
1. Install virtual environment for python
This is additional package which is used to provide your future application personal python version.
$ sudo apt-get install python-virtualenv
2. Create your future project directory
Suppose first will be hello_world:
$ mkdir hello_world
3. Create virtual environment for your hello_world project
Suppose virtual environment name will be venv:
$cd ./hello_world
$ virtualenv venv
I had output like that:
New python executable in venv/bin/python
Installing setuptools, pip...done.
4. Activate your environment
$. venv/bin/activate
How your shell prompt should begin from (venv).
5. Create file hello_world.py in current directory with next content:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
6. Start application listening on 5000 port
$ python hello_world.py
* Running on http://127.0.0.1:5000/
No comments:
Post a Comment