Starting with 2.1, PTVS supports Flask projects. 

 

About Flask

If you are new to Flask, please check out http://flask.pocoo.org/ where you can get more information, tutorials, samples, etc.

PTVS Flask Quick Start

You can create one via File/New/Project/Python and selecting “Flask Web Project”:

image_thumb[20]

The default “Hello World” looks like this:

image_thumb[21]

Flask Installation

If you don’t have Flask installed, you can do so from inside PTVS by creating a Virtual Environment and using pip.  Here let’s assume that you’ve already installed CPython 2.7:

1. Right click on Python Environments and select Add Virtual Environment:

image_thumb[6]

2. When prompted with a list, select 2.7:

image_thumb[8]

3. Once the Environment is created, right click on it and select Install Python Package… :

image_thumb[10]

4. Enter Flask, which will install the latest version or specify a particular version via “==” :

image_thumb[22]

You will see some output regarding the installation and finally see Flas, jinja2, etc. in your Environment.  At this point let’s set a breakpoint and hit F5:

image_thumb[14]

As with any other Python project, you can use the various debugging features:

image_thumb[24]

Here once you hit Continue, you should see your browser pop up with “Hello World” at the specified port:

image_thumb[19]

Publishing to Azure

The steps for Publishing to Azure Web Sites and Cloud Service are identical to those of Django.  Please see the tail end of this tutorial for instructions:

https://pytools.codeplex.com/wikipage?title=Django%20Web%20Site%2fCloud%20Service%20Tutorial

Last edited Feb 11 at 11:16 PM by ptools, version 2

Comments

No comments yet.