Install Flask with Easy Steps in Windows

If you were looking for a quick tutorial on how to install Flask in Python for web developement applications, you're in the right place. I'm using Python 3.4 since already has PIP installed, which we're going to use to install Flask. (Python 2.7 doesn't include the PIP). Let's begin:

1. You need to head over the Environment Variables of your system.


2. Control Panel > Advanced System Settings > Environment Variables > System Variables


3. Choose Path

You should see a large path. In the end just add this: ;C:\Python34\Scripts if it isn't already there. Note that the semicolon in the start you need to add it only when there is something like "C:\Someprogram\ ".
-> If that was the case, the final result would be: C:\Someprogram\;C:\Python34\Scripts

4. Open Console: Press "Windows Key" + R, type cmd,hit "Enter" and type the following commands in order:

          cd \
          pip install virtualenv
          mkdir pythonWebsite
          cd pythonWebsite
          virtualenv flask
          flask\Scripts\pip install flask
          mkdir myWebsite
          cd myWebsite
          mkdir templates
          mkdir static

Open a new python file and paste the following code

5. Creating the __init__ file

from flask import Flask
app = Flask(__name__)
@app.route('/')

def index():
      return "This is my first site in python"

if __name__ == "__main__":
      app.run()
Save file as __init__.py inside your myWebsite folder.

6. Type commands in order:

          cd ..
          cd flask\Scripts
          activate
          cd ..
          cd ..
          cd myWebsite
          You should see something like: (flask) C:\pythonWebsite\myWebsite>

Finally type:
          python __init__.py

You can see that something's running and there is an ip. Usually it's something like: 127.0.0.1:5000. Copy that ip and paste it in the url of your browser. Now you can see your website.

Have fun coding!

python.org | Contact Me | © ksoftware.eu 2016