<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>flask on C'est la Z</title><link>https://cestlaz.github.io/cestlaz-old-hugo.github.io/tags/flask/</link><description>C'est la Z (flask)</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sat, 15 Oct 2016 00:00:00 +0000</lastBuildDate><atom:link href="https://cestlaz.github.io/cestlaz-old-hugo.github.io/tags/flask/rss.xml" rel="self" type="application/rss"/><item><title>Installing Flask in a virtualenv</title><link>https://cestlaz.github.io/cestlaz-old-hugo.github.io/posts/flask-install-flask/</link><pubDate>Sat, 15 Oct 2016 00:00:00 +0000</pubDate><guid>https://cestlaz.github.io/cestlaz-old-hugo.github.io/posts/flask-install-flask/</guid><description>&lt;p>
Second video in the Flask series. This one goes over installing Flask
in a virtualenv and running a simple Flask application.&lt;/p>
&lt;p>
Nothing much to say about this other then check out the video:&lt;/p>
&lt;iframe width="560" height="315" src="https://www.youtube.com/embed/2ZIhczsu1EQ" frameborder="0" allowfullscreen>&lt;/iframe></description></item><item><title>Setting up Linux for Flask Web Development</title><link>https://cestlaz.github.io/cestlaz-old-hugo.github.io/posts/flask-setup-virtualenv/</link><pubDate>Fri, 14 Oct 2016 00:00:00 +0000</pubDate><guid>https://cestlaz.github.io/cestlaz-old-hugo.github.io/posts/flask-setup-virtualenv/</guid><description>&lt;p>
Those laptops that my Hunter students were supposed to get have
finally arrived. We&amp;#39;re distributing them on Monday. Each student will
have a Dell laptop running Ubuntu 16.04 for as long as they&amp;#39;re in the
program.&lt;/p>
&lt;p>
This means we can finally start using the web as a way of displaying
and sharing our projects.&lt;/p>
&lt;p>
For this type of web development, I&amp;#39;m a big fan of using &lt;a href="http://flask.pocoo.org">Flask&lt;/a>. Flask
is a Python microframework. The easiest analogy is saying it&amp;#39;s like
Ruby on rails but in Python. That&amp;#39;s close enough for our purposes.&lt;/p>
&lt;p>
I much prefer Python to Ruby as a teaching tool because it leads to
roads going in all sorts of directions so it was merely a matter of
figuring out which framework or platform to use. I found Django to be
far too big, cumbersome, and all encompasing while on the other hand,
&lt;a href="http://werkzeug.pocoo.org/">Werkzeug&lt;/a>, which Flask is based on is a little too low level.&lt;/p>
&lt;p>
Flask hit the sweet spot. Easy routing, session and form handling,
templates, pretty much everything I was looking for but very
unopinionated and open ended. Perfect for teaching and learning and
perfect for lightweight projects. The sourecode is also
straightforward enough for a student to explore.&lt;/p>
&lt;p>
Below is a video going over setting up Linux from right after an
install to use the python virtualenv package. The next video will go
over installing Flask and setting up a simple application. Later, I&amp;#39;ll
post a video on deployment to a &lt;a href="http://digitalocean.com">Digital Ocean&lt;/a> Droplet.&lt;/p>
&lt;p>
Here are some notes relating to the video.&lt;/p>
&lt;p>
First, go to your &amp;#34;software sources&amp;#34; or &amp;#34;software updates&amp;#34;
application from the menu and select all the sources (as described n
the video)&lt;/p>
&lt;p>
To update a new system:&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>sudo apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get upgrade
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get dist-upgade&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;p>
To install the most recent emacs snapshot&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>sudo apt-add repository -y ppa:ubuntu-lisp
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get install emacs-snapshot&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;p>
To install python pip (used to install other python packages)&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>sudo apt-get install python-pip&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;p>
and then to install the virtualenv packages&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>sudo pip install virtualenv&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;p>
To create a python3 virtual environment&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>pip install -p python3 venv-folder&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;ul>
&lt;li>You can activate the envorinment (assuming you create the folder under&lt;/li>
&lt;/ul>
&lt;p>your home directory):&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>source ~/venv-folder/bin/activate&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;p>
And to deactivate it, from the activated terminal&lt;/p>
&lt;div class="src src-sh">
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>deactivate&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/div>
&lt;p>
Here&amp;#39;s the video. Next time, we&amp;#39;ll install Flask into an virtual
environment.&lt;/p>
&lt;iframe width="560" height="315" src="https://www.youtube.com/embed/cEqB4pkR1c4" frameborder="0" allowfullscreen>&lt;/iframe></description></item></channel></rss>