SlideShare a Scribd company logo
Flask in details
           Max Klymyshyn
        CTO at GVMahines

          @maxmaxmaxmax
            github: joymax
From Django to Flask

    and back to Django
I remember when Flask appeared

And I was one of guys who hadn't
         read the code
  when Flask was just a joke.
LvivPy - Flask in details
But Armin is
really nice,
simple and
very smart guy
And when I start worked with Flask,
              aam...
LvivPy - Flask in details
Now I feel like ...
NA NA NA
Devil is in the details
Here is details
1. Typical project structure
2. Blueprints
3. Database
4. Forms & Validation
5. Management Commands
6. Assets-management
7. Replacement of django.contrib.admin
8. Debugging
9. Unit tests and Behavior tests
Project structure
1. pure python module:

 settings.py
 - project
   - app.py
   - views.py
   - templates
   - static
   ...

2. Configuration: local_settings, settings:

app.config.from_object(settings)
Blueprints
Kind of django-apps
1. Initialization:
from flask import Blueprint
app = Blueprint(
       'profile', // namespace
       __name__, // logical python module or
                   // package
       template_folder='templates',
       static_folder='static'
       )
...
@app.route('/sample/')
def sample():
       ...
Register blueprint
1. To register use app.register_blueprint :
      from flask import Flask
      from proj.submodule.bp import app as
submodule

      app = Flask(__name__)
      app.register_blueprint(
          submodule,
          url_prefix='/submodule'
      )
2. Url namespace
{{ url_for('profile.sample') }}
Database
Flask-SQLAlchemy
    minimongo
    Flask-Redis
Flask-SQLAlchemy
Example configuration from docs:

from flask import Flask
from flaskext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 
    'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
Flask-SQLAlchemy
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(
        db.String(80), unique=True)
    email = db.Column(
        db.String(120), unique=True)

    def __init__(self, username, email):
        self.username = username
        self.email = email

    def __repr__(self):
        return '<User %r>' % self.username
Flask-SQLAlchemy
>>> from app import db
>>> db.create_all()
>>> from app import User
>>> admin = User('admin', 'admin@example.com')
>>> guest = User('guest', 'guest@example.com')
>>> db.session.add(admin)
>>> db.session.add(guest)
>>> db.session.commit()
>>> User.query.all()
[<User u'admin'>, <User u'guest'>]
Minimongo
 1. No initial configuration needed
 2. Install & start mongo - that's enough
Sample model:

import minimongo as mm

class Profile(mm.Model):
    class Meta:
        database = "sampleproject"
        collection = "profiles"

           indices = (mm.Index('username'))
Minimongo
>>> from app import db, User, Profile
>>> admin = User.query.filter_by(
... username='admin').first()
>>> admin.username
u'admin'
>>> profile = Profile(username=admin.username,
... description=u'Flask devleoper')
>>> profile
{'username': u'admin', 'description': u'Flask
devleoper'}
>>> profile.save()
{'username': u'admin', '_id':
ObjectId('4f13e019486dd09335000001'), 'description':
u'Flask devleoper'}
Minimongo
>>> Profile.collection
Collection(Database(Connection('localhost',
27017), u'sampleproject'), u'profiles')

>>> Profile.collection.find_one(
... {'username': admin.username})
{u'username': u'admin', u'_id':
ObjectId('4f13df60486dd09335000000'),
u'description': u'Flask devleoper'}
Flask-Redis
1. Install flask-redis
2. Add to app.py:
from flask.ext.redis import init_redis
...
redis = init_redis(app)
2. Quite easy to use:
>>> from app import redis
>>> p = redis.pipeline()
>>> p.set("username", "admin")
<redis.client.Pipeline object at 0x10139b350>
>>> p.execute()
[True]
>>> redis.get("username")
'admin'
Forms & Validation

     Flask-WTF
WTForms Form and View
from flask.ext import wtf

class UserForm(wtf.Form):
    username = wtf.TextField("Username", [wtf.Required()])
    email = wtf.TextField(
        "Email", [wtf.Required(), wtf.Email()])

@app.route('/form', methods=['POST', 'GET'])
def form():
    form = UserForm()
    if form.validate_on_submit():
        flash("Success")
        return redirect("/form")
    return render_template("form.html", form=form)
WTForm Template
{% with messages = get_flashed_messages() %}
    {{ ", ".join(messages or []) }}
{% endwith %}
<hr />

<form method="post" action="/form">{{ form.csrf }}
    <i>{{ "; ".join(form.username.errors) }}</i>
    <br />
    {{ form.username(size=20) }}
    <hr />
    {{ "; ".join(form.email.errors) }}<br />
    {{ form.email(size=20) }}
    <hr />
    <input type="submit" value="Go">
</form>
Management Commands

Write external scripts with current
         project context
Flask-Script
1. Create manage.py script within your project directory and put
(which is quite similar to Django's manage.py):

from flaskext.script import Manager
from app import app

manager = Manager(app)

@manager.command
def hello():
    print "hello"

if __name__ == "__main__":
    manager.run()
Flask-Script
maxk$ python manage.py
  shell      Runs a Python shell inside
Flask application context.
  hello
  runserver Runs the Flask development
server i.e. app.run()

maxk$ python manage.py hello
hello
Flask-Script
With Flask-Script you able to:

•   Write custom management commands
•   Use existing ones like in flask-assets
•   Getting user's input
•   Use command line options

All of abilities above already automated with Flask-Script and
it's really easy-to-use.
Assets Management

Static, CSS & JavaScript files
JS/CSS minification and so on
Flask-Assets based on Webassets. To integrate we
need some work to do:

1. Install Flask-Assets
2. Initialize Flask-Assets environment
3. Add Assets Bundles
4. Configure compressors/minifiers etc. to optimize
   our assets
5. Generate bundles with management command
Flask-Assets: initializing environment
import Flask
from flask.ext.assets import Environment as
AssetsEnvironment

app = Flask(__name__)
assets = AssetsEnvironment(app)
assets.debug = True

app.config['ASSETS_DEBUG'] = True

app.config['YUI_COMPRESSOR_PATH'] = 'contrib/
yuicompressor-2.4.6.jar'
Flask-Assets: Adding files
I will show work with JavaScript only but feel free to use same
approach with CSS files.
JavaScript files directory structure:

 - static
   - js
- src
- core
* jquery.js
* underscore.js
- app
* module1.js
* module2.js
Flask-Assets: adding bundles
assets.py:

from flaskext.assets import Bundle

def register_assets(assets):
    core = Bundle(
        'js/src/core/jquery.js',
        'js/src/core/underscore.js',
        filters='yui_js',
        output='js/bundle/core.js'
    )
    assets.register('core', core)
Flask-Assets: adding bundles
...
app = Bundle(
    'js/src/app/*.js',
    filters='yui_js',
    output='js/bundle/app.js'
)

assets.register('app', app)
LvivPy - Flask in details
Flask-Assets: how to use
Somewhere in your template code:

{% assets "core" %}
    <script src="{{ ASSET_URL }}"></script>
{% endassets %}

{% assets "app" %}
    <script src="{{ ASSET_URL }}"></script>
{% endassets %}
Flask-Assets: debug mode
Flask-Assets generate code below (debug mode):
<script src="/static/js/src/core/jquery.js"></
script>
<script src="/static/js/src/core/underscore.js"></
script>

<script src="/static/js/src/app/module1.js"></
script>
<script src="/static/js/src/app/module2.js"></
script>
Flask-Assets: production mode
Flask-Assets generate code below (production mode):

<script src="/static/js/bundles/core.js"></script>
<script src="/static/js/bundles/app.js"></script>

Static files was generated with Flask-Script command:

maxk$ python manage.py assets rebuild
More extensions:
    Flask-Mail
     Flask-Babel
     Flask-Cache
      Flask-csrf
   Flask-FlatPages
    Flask-lesscss
          ...
Admin panel

 Flask-Admin
 Flask-Dashed
Tests

Unit, Behavior and JavaScript tests
LvivPy - Flask in details
Testing: Unit & Behavior
To test templates, views etc we need to have request context

Before execution:

self.app.test_request_context().push()

After execution:

self.app.test_request_context().pop()
Behavior Testes with Lettuce
Example feature and scenario:

Feature: Auth
     Scenario: Sign In as featured expert
            When I go to "auth.login" view
            Then I see that response code is 200
           And There's form with following fields:
                   | form__username |
                   | form__password |
            Fill the field "form__username" with "featured"
lettuce-web
Lettuce-web is a library which very close to headless testing
using twill. lettuce-web doesn't require browser. You can
write your features using lettuce-web predefined steps.



                       More here:
        https://github.com/joymax/lettuce-web
Flask-Jasmine
Flask-Jasmine is extension to execute Jasmine JavaScript
Tests



                       More details
        https://github.com/joymax/flask-jasmine
Debugging

Flask-DebugToolbar
werkzeug debugger
Issues

What's going on in Flask world at
          the moment?
Python 3
Status of porting Flask to Python 3 is unknown.

Werkzeug not ported yet. Hopefully, will be ported to Python
3.3 ( PEP 414 for details)
Werkzeug
Werkzeug is really huge and have tons of tools.
Flask based on Werkzeug.

We all like Python for small, robust and clean libraries.
What’s next?




Flask 0.9
                52
That's all
                  Questions?


                    Source: 
https://github.com/joymax/kyivpy-flask-in-details
LvivPy - Flask in details
Ad

More Related Content

What's hot (20)

Build restful ap is with python and flask
Build restful ap is with python and flaskBuild restful ap is with python and flask
Build restful ap is with python and flask
Jeetendra singh
 
Flask
FlaskFlask
Flask
Mamta Kumari
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
Alexey Popravka
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
Larry Cai
 
Python Flask app deployed to OPenShift using Wercker CI
Python Flask app deployed to OPenShift using Wercker CIPython Flask app deployed to OPenShift using Wercker CI
Python Flask app deployed to OPenShift using Wercker CI
Bruno Rocha
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
Alessandro Cucci
 
Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuth
Eueung Mulyana
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Flask vs. Django
Flask vs. DjangoFlask vs. Django
Flask vs. Django
Rachel Sanders
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
Nathan Eror
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
Vikas Chauhan
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
Kishimi Ibrahim Ishaq
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
postrational
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentials
Pramod Kadam
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
MasterCode.vn
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
Sudip Simkhada
 
Laravel 101
Laravel 101Laravel 101
Laravel 101
Commit University
 
Installation of Joomla on Windows XP
Installation of Joomla on Windows XPInstallation of Joomla on Windows XP
Installation of Joomla on Windows XP
Rupesh Kumar
 
Build restful ap is with python and flask
Build restful ap is with python and flaskBuild restful ap is with python and flask
Build restful ap is with python and flask
Jeetendra singh
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
Larry Cai
 
Python Flask app deployed to OPenShift using Wercker CI
Python Flask app deployed to OPenShift using Wercker CIPython Flask app deployed to OPenShift using Wercker CI
Python Flask app deployed to OPenShift using Wercker CI
Bruno Rocha
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
Alessandro Cucci
 
Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuth
Eueung Mulyana
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
Nathan Eror
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
Vikas Chauhan
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
postrational
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentials
Pramod Kadam
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides4 introduction-php-mvc-cakephp-m4-controllers-slides
4 introduction-php-mvc-cakephp-m4-controllers-slides
MasterCode.vn
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
Installation of Joomla on Windows XP
Installation of Joomla on Windows XPInstallation of Joomla on Windows XP
Installation of Joomla on Windows XP
Rupesh Kumar
 

Viewers also liked (20)

Python and Flask introduction for my classmates Презентация и введение в flask
Python and Flask introduction for my classmates Презентация и введение в flaskPython and Flask introduction for my classmates Презентация и введение в flask
Python and Flask introduction for my classmates Презентация и введение в flask
Nikita Lozhnikov
 
Snakes on the Web
Snakes on the WebSnakes on the Web
Snakes on the Web
Jacob Kaplan-Moss
 
Introduction to Python and Web Programming
Introduction to Python and Web ProgrammingIntroduction to Python and Web Programming
Introduction to Python and Web Programming
David Neiss
 
Python and the Web
Python and the WebPython and the Web
Python and the Web
pycontw
 
Flask admin vs. DIY
Flask admin vs. DIYFlask admin vs. DIY
Flask admin vs. DIY
dokenzy
 
Why Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the WebWhy Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the Web
joelburton
 
Спецификация WSGI (PEP-333)
Спецификация WSGI (PEP-333)Спецификация WSGI (PEP-333)
Спецификация WSGI (PEP-333)
lectureswww lectureswww
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twisted
sdsern
 
Python talk web frameworks
Python talk web frameworksPython talk web frameworks
Python talk web frameworks
Kat Chuang
 
Зоопарк python веб-фреймворков
Зоопарк python веб-фреймворковЗоопарк python веб-фреймворков
Зоопарк python веб-фреймворков
PyNSK
 
Чем Python плох для стартапа?
Чем Python плох для стартапа?Чем Python плох для стартапа?
Чем Python плох для стартапа?
PyNSK
 
CHC Thesis #1
CHC Thesis #1CHC Thesis #1
CHC Thesis #1
CHCStaff
 
STS Thesis by Hall 2015
STS Thesis by Hall 2015STS Thesis by Hall 2015
STS Thesis by Hall 2015
Hank Lydick
 
Asynchronous Python with Twisted
Asynchronous Python with TwistedAsynchronous Python with Twisted
Asynchronous Python with Twisted
Adam Englander
 
Writing your first web app using Python and Flask
Writing your first web app using Python and FlaskWriting your first web app using Python and Flask
Writing your first web app using Python and Flask
Danielle Madeley
 
Django vs Flask
Django vs FlaskDjango vs Flask
Django vs Flask
Rachel Sanders
 
Framework Battle: Django vs Flask vs Chalice
Framework Battle: Django vs Flask vs ChaliceFramework Battle: Django vs Flask vs Chalice
Framework Battle: Django vs Flask vs Chalice
STEP Computer Academy (Zaporozhye)
 
Python and you
Python and youPython and you
Python and you
Sian Lerk Lau
 
Async Web Frameworks in Python
Async Web Frameworks in PythonAsync Web Frameworks in Python
Async Web Frameworks in Python
Ryan Johnson
 
Web Scraping with Python
Web Scraping with PythonWeb Scraping with Python
Web Scraping with Python
Paul Schreiber
 
Python and Flask introduction for my classmates Презентация и введение в flask
Python and Flask introduction for my classmates Презентация и введение в flaskPython and Flask introduction for my classmates Презентация и введение в flask
Python and Flask introduction for my classmates Презентация и введение в flask
Nikita Lozhnikov
 
Introduction to Python and Web Programming
Introduction to Python and Web ProgrammingIntroduction to Python and Web Programming
Introduction to Python and Web Programming
David Neiss
 
Python and the Web
Python and the WebPython and the Web
Python and the Web
pycontw
 
Flask admin vs. DIY
Flask admin vs. DIYFlask admin vs. DIY
Flask admin vs. DIY
dokenzy
 
Why Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the WebWhy Python Web Frameworks Are Changing the Web
Why Python Web Frameworks Are Changing the Web
joelburton
 
An Introduction to Twisted
An Introduction to TwistedAn Introduction to Twisted
An Introduction to Twisted
sdsern
 
Python talk web frameworks
Python talk web frameworksPython talk web frameworks
Python talk web frameworks
Kat Chuang
 
Зоопарк python веб-фреймворков
Зоопарк python веб-фреймворковЗоопарк python веб-фреймворков
Зоопарк python веб-фреймворков
PyNSK
 
Чем Python плох для стартапа?
Чем Python плох для стартапа?Чем Python плох для стартапа?
Чем Python плох для стартапа?
PyNSK
 
CHC Thesis #1
CHC Thesis #1CHC Thesis #1
CHC Thesis #1
CHCStaff
 
STS Thesis by Hall 2015
STS Thesis by Hall 2015STS Thesis by Hall 2015
STS Thesis by Hall 2015
Hank Lydick
 
Asynchronous Python with Twisted
Asynchronous Python with TwistedAsynchronous Python with Twisted
Asynchronous Python with Twisted
Adam Englander
 
Writing your first web app using Python and Flask
Writing your first web app using Python and FlaskWriting your first web app using Python and Flask
Writing your first web app using Python and Flask
Danielle Madeley
 
Async Web Frameworks in Python
Async Web Frameworks in PythonAsync Web Frameworks in Python
Async Web Frameworks in Python
Ryan Johnson
 
Web Scraping with Python
Web Scraping with PythonWeb Scraping with Python
Web Scraping with Python
Paul Schreiber
 
Ad

Similar to LvivPy - Flask in details (20)

Filling the flask
Filling the flaskFilling the flask
Filling the flask
Jason Myers
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIs
Bruno Rocha
 
Developing Flask Extensions
Developing Flask ExtensionsDeveloping Flask Extensions
Developing Flask Extensions
Rachel Sanders
 
Django tricks (2)
Django tricks (2)Django tricks (2)
Django tricks (2)
Carlos Hernando
 
Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
Fabien Potencier
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
Astrails
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial
Katy Slemon
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
Solution4Future
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
Leonardo Fernandes
 
A I R Presentation Dev Camp Feb 08
A I R  Presentation  Dev Camp  Feb 08A I R  Presentation  Dev Camp  Feb 08
A I R Presentation Dev Camp Feb 08
Abdul Qabiz
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Codemotion
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
Lar21
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
Brendan Sera-Shriar
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson
Dev_Events
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Jérémy Derussé
 
Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
Felipe Queiroz
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
Yuriy Senko
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
Jason Myers
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIs
Bruno Rocha
 
Developing Flask Extensions
Developing Flask ExtensionsDeveloping Flask Extensions
Developing Flask Extensions
Rachel Sanders
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
Astrails
 
Flask jwt authentication tutorial
Flask jwt authentication tutorialFlask jwt authentication tutorial
Flask jwt authentication tutorial
Katy Slemon
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
Solution4Future
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
Leonardo Fernandes
 
A I R Presentation Dev Camp Feb 08
A I R  Presentation  Dev Camp  Feb 08A I R  Presentation  Dev Camp  Feb 08
A I R Presentation Dev Camp Feb 08
Abdul Qabiz
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Codemotion
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
Lar21
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson
Dev_Events
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Jérémy Derussé
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
Yuriy Senko
 
Ad

More from Max Klymyshyn (20)

Papers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON Datatype
Papers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON DatatypePapers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON Datatype
Papers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON Datatype
Max Klymyshyn
 
KharkivJS 2017: Коллаборативные системы и CRDT
KharkivJS 2017: Коллаборативные системы и CRDTKharkivJS 2017: Коллаборативные системы и CRDT
KharkivJS 2017: Коллаборативные системы и CRDT
Max Klymyshyn
 
OdessaJS 2017: Groupware Systems for fun and profit
OdessaJS 2017: Groupware Systems for fun and profitOdessaJS 2017: Groupware Systems for fun and profit
OdessaJS 2017: Groupware Systems for fun and profit
Max Klymyshyn
 
PyCon Ukraine 2017: Operational Transformation
PyCon Ukraine 2017: Operational Transformation PyCon Ukraine 2017: Operational Transformation
PyCon Ukraine 2017: Operational Transformation
Max Klymyshyn
 
Communicating Sequential Processes (CSP) in JavaScript
Communicating Sequential Processes (CSP) in JavaScriptCommunicating Sequential Processes (CSP) in JavaScript
Communicating Sequential Processes (CSP) in JavaScript
Max Klymyshyn
 
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PiterPy 2016: Parallelization, Aggregation and Validation of API in PythonPiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
Max Klymyshyn
 
Fighting async JavaScript (CSP)
Fighting async JavaScript (CSP)Fighting async JavaScript (CSP)
Fighting async JavaScript (CSP)
Max Klymyshyn
 
React.js: Ускоряем UX/UI
React.js: Ускоряем UX/UIReact.js: Ускоряем UX/UI
React.js: Ускоряем UX/UI
Max Klymyshyn
 
KharkovPy #12: I/O in Python apps and smart logging (russian)
KharkovPy #12: I/O in Python apps and smart logging (russian)KharkovPy #12: I/O in Python apps and smart logging (russian)
KharkovPy #12: I/O in Python apps and smart logging (russian)
Max Klymyshyn
 
5 мифов о производительности баз данных и Python
5 мифов о производительности баз данных и Python5 мифов о производительности баз данных и Python
5 мифов о производительности баз данных и Python
Max Klymyshyn
 
Изоформные приложения на React.js
Изоформные приложения на React.jsИзоформные приложения на React.js
Изоформные приложения на React.js
Max Klymyshyn
 
Изоморфный JavaScript (iForum 2015)
Изоморфный JavaScript (iForum 2015)Изоморфный JavaScript (iForum 2015)
Изоморфный JavaScript (iForum 2015)
Max Klymyshyn
 
Трансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScript
Трансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScriptТрансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScript
Трансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScript
Max Klymyshyn
 
PiterPy 2015 - Трансдюсеры и Python
PiterPy 2015 - Трансдюсеры и PythonPiterPy 2015 - Трансдюсеры и Python
PiterPy 2015 - Трансдюсеры и Python
Max Klymyshyn
 
Robust web apps with React.js
Robust web apps with React.jsRobust web apps with React.js
Robust web apps with React.js
Max Klymyshyn
 
LvivJS 2014 - Win-win c React.js
LvivJS 2014 - Win-win c React.jsLvivJS 2014 - Win-win c React.js
LvivJS 2014 - Win-win c React.js
Max Klymyshyn
 
Инновации и JavaScript
Инновации и JavaScriptИнновации и JavaScript
Инновации и JavaScript
Max Klymyshyn
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and Python
Max Klymyshyn
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
Max Klymyshyn
 
Зачем читать чужой код?
Зачем читать чужой код?Зачем читать чужой код?
Зачем читать чужой код?
Max Klymyshyn
 
Papers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON Datatype
Papers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON DatatypePapers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON Datatype
Papers We Love Kyiv, July 2018: A Conflict-Free Replicated JSON Datatype
Max Klymyshyn
 
KharkivJS 2017: Коллаборативные системы и CRDT
KharkivJS 2017: Коллаборативные системы и CRDTKharkivJS 2017: Коллаборативные системы и CRDT
KharkivJS 2017: Коллаборативные системы и CRDT
Max Klymyshyn
 
OdessaJS 2017: Groupware Systems for fun and profit
OdessaJS 2017: Groupware Systems for fun and profitOdessaJS 2017: Groupware Systems for fun and profit
OdessaJS 2017: Groupware Systems for fun and profit
Max Klymyshyn
 
PyCon Ukraine 2017: Operational Transformation
PyCon Ukraine 2017: Operational Transformation PyCon Ukraine 2017: Operational Transformation
PyCon Ukraine 2017: Operational Transformation
Max Klymyshyn
 
Communicating Sequential Processes (CSP) in JavaScript
Communicating Sequential Processes (CSP) in JavaScriptCommunicating Sequential Processes (CSP) in JavaScript
Communicating Sequential Processes (CSP) in JavaScript
Max Klymyshyn
 
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PiterPy 2016: Parallelization, Aggregation and Validation of API in PythonPiterPy 2016: Parallelization, Aggregation and Validation of API in Python
PiterPy 2016: Parallelization, Aggregation and Validation of API in Python
Max Klymyshyn
 
Fighting async JavaScript (CSP)
Fighting async JavaScript (CSP)Fighting async JavaScript (CSP)
Fighting async JavaScript (CSP)
Max Klymyshyn
 
React.js: Ускоряем UX/UI
React.js: Ускоряем UX/UIReact.js: Ускоряем UX/UI
React.js: Ускоряем UX/UI
Max Klymyshyn
 
KharkovPy #12: I/O in Python apps and smart logging (russian)
KharkovPy #12: I/O in Python apps and smart logging (russian)KharkovPy #12: I/O in Python apps and smart logging (russian)
KharkovPy #12: I/O in Python apps and smart logging (russian)
Max Klymyshyn
 
5 мифов о производительности баз данных и Python
5 мифов о производительности баз данных и Python5 мифов о производительности баз данных и Python
5 мифов о производительности баз данных и Python
Max Klymyshyn
 
Изоформные приложения на React.js
Изоформные приложения на React.jsИзоформные приложения на React.js
Изоформные приложения на React.js
Max Klymyshyn
 
Изоморфный JavaScript (iForum 2015)
Изоморфный JavaScript (iForum 2015)Изоморфный JavaScript (iForum 2015)
Изоморфный JavaScript (iForum 2015)
Max Klymyshyn
 
Трансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScript
Трансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScriptТрансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScript
Трансдюсеры, CSP каналы, неизменяемые структуры данных в JavaScript
Max Klymyshyn
 
PiterPy 2015 - Трансдюсеры и Python
PiterPy 2015 - Трансдюсеры и PythonPiterPy 2015 - Трансдюсеры и Python
PiterPy 2015 - Трансдюсеры и Python
Max Klymyshyn
 
Robust web apps with React.js
Robust web apps with React.jsRobust web apps with React.js
Robust web apps with React.js
Max Klymyshyn
 
LvivJS 2014 - Win-win c React.js
LvivJS 2014 - Win-win c React.jsLvivJS 2014 - Win-win c React.js
LvivJS 2014 - Win-win c React.js
Max Klymyshyn
 
Инновации и JavaScript
Инновации и JavaScriptИнновации и JavaScript
Инновации и JavaScript
Max Klymyshyn
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and Python
Max Klymyshyn
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
Max Klymyshyn
 
Зачем читать чужой код?
Зачем читать чужой код?Зачем читать чужой код?
Зачем читать чужой код?
Max Klymyshyn
 

Recently uploaded (20)

Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 

LvivPy - Flask in details

  • 1. Flask in details Max Klymyshyn CTO at GVMahines @maxmaxmaxmax github: joymax
  • 2. From Django to Flask and back to Django
  • 3. I remember when Flask appeared And I was one of guys who hadn't read the code when Flask was just a joke.
  • 5. But Armin is really nice, simple and very smart guy
  • 6. And when I start worked with Flask, aam...
  • 8. Now I feel like ...
  • 10. Devil is in the details
  • 11. Here is details 1. Typical project structure 2. Blueprints 3. Database 4. Forms & Validation 5. Management Commands 6. Assets-management 7. Replacement of django.contrib.admin 8. Debugging 9. Unit tests and Behavior tests
  • 12. Project structure 1. pure python module: settings.py - project - app.py - views.py - templates - static ... 2. Configuration: local_settings, settings: app.config.from_object(settings)
  • 13. Blueprints Kind of django-apps 1. Initialization: from flask import Blueprint app = Blueprint( 'profile', // namespace __name__, // logical python module or // package template_folder='templates', static_folder='static' ) ... @app.route('/sample/') def sample(): ...
  • 14. Register blueprint 1. To register use app.register_blueprint : from flask import Flask from proj.submodule.bp import app as submodule app = Flask(__name__) app.register_blueprint( submodule, url_prefix='/submodule' ) 2. Url namespace {{ url_for('profile.sample') }}
  • 15. Database Flask-SQLAlchemy minimongo Flask-Redis
  • 16. Flask-SQLAlchemy Example configuration from docs: from flask import Flask from flaskext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' db = SQLAlchemy(app)
  • 17. Flask-SQLAlchemy class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column( db.String(80), unique=True) email = db.Column( db.String(120), unique=True) def __init__(self, username, email): self.username = username self.email = email def __repr__(self): return '<User %r>' % self.username
  • 18. Flask-SQLAlchemy >>> from app import db >>> db.create_all() >>> from app import User >>> admin = User('admin', '[email protected]') >>> guest = User('guest', '[email protected]') >>> db.session.add(admin) >>> db.session.add(guest) >>> db.session.commit() >>> User.query.all() [<User u'admin'>, <User u'guest'>]
  • 19. Minimongo 1. No initial configuration needed 2. Install & start mongo - that's enough Sample model: import minimongo as mm class Profile(mm.Model): class Meta: database = "sampleproject" collection = "profiles" indices = (mm.Index('username'))
  • 20. Minimongo >>> from app import db, User, Profile >>> admin = User.query.filter_by( ... username='admin').first() >>> admin.username u'admin' >>> profile = Profile(username=admin.username, ... description=u'Flask devleoper') >>> profile {'username': u'admin', 'description': u'Flask devleoper'} >>> profile.save() {'username': u'admin', '_id': ObjectId('4f13e019486dd09335000001'), 'description': u'Flask devleoper'}
  • 21. Minimongo >>> Profile.collection Collection(Database(Connection('localhost', 27017), u'sampleproject'), u'profiles') >>> Profile.collection.find_one( ... {'username': admin.username}) {u'username': u'admin', u'_id': ObjectId('4f13df60486dd09335000000'), u'description': u'Flask devleoper'}
  • 22. Flask-Redis 1. Install flask-redis 2. Add to app.py: from flask.ext.redis import init_redis ... redis = init_redis(app) 2. Quite easy to use: >>> from app import redis >>> p = redis.pipeline() >>> p.set("username", "admin") <redis.client.Pipeline object at 0x10139b350> >>> p.execute() [True] >>> redis.get("username") 'admin'
  • 23. Forms & Validation Flask-WTF
  • 24. WTForms Form and View from flask.ext import wtf class UserForm(wtf.Form): username = wtf.TextField("Username", [wtf.Required()]) email = wtf.TextField( "Email", [wtf.Required(), wtf.Email()]) @app.route('/form', methods=['POST', 'GET']) def form(): form = UserForm() if form.validate_on_submit(): flash("Success") return redirect("/form") return render_template("form.html", form=form)
  • 25. WTForm Template {% with messages = get_flashed_messages() %} {{ ", ".join(messages or []) }} {% endwith %} <hr /> <form method="post" action="/form">{{ form.csrf }} <i>{{ "; ".join(form.username.errors) }}</i> <br /> {{ form.username(size=20) }} <hr /> {{ "; ".join(form.email.errors) }}<br /> {{ form.email(size=20) }} <hr /> <input type="submit" value="Go"> </form>
  • 26. Management Commands Write external scripts with current project context
  • 27. Flask-Script 1. Create manage.py script within your project directory and put (which is quite similar to Django's manage.py): from flaskext.script import Manager from app import app manager = Manager(app) @manager.command def hello(): print "hello" if __name__ == "__main__": manager.run()
  • 28. Flask-Script maxk$ python manage.py shell Runs a Python shell inside Flask application context. hello runserver Runs the Flask development server i.e. app.run() maxk$ python manage.py hello hello
  • 29. Flask-Script With Flask-Script you able to: • Write custom management commands • Use existing ones like in flask-assets • Getting user's input • Use command line options All of abilities above already automated with Flask-Script and it's really easy-to-use.
  • 30. Assets Management Static, CSS & JavaScript files
  • 31. JS/CSS minification and so on Flask-Assets based on Webassets. To integrate we need some work to do: 1. Install Flask-Assets 2. Initialize Flask-Assets environment 3. Add Assets Bundles 4. Configure compressors/minifiers etc. to optimize our assets 5. Generate bundles with management command
  • 32. Flask-Assets: initializing environment import Flask from flask.ext.assets import Environment as AssetsEnvironment app = Flask(__name__) assets = AssetsEnvironment(app) assets.debug = True app.config['ASSETS_DEBUG'] = True app.config['YUI_COMPRESSOR_PATH'] = 'contrib/ yuicompressor-2.4.6.jar'
  • 33. Flask-Assets: Adding files I will show work with JavaScript only but feel free to use same approach with CSS files. JavaScript files directory structure: - static - js - src - core * jquery.js * underscore.js - app * module1.js * module2.js
  • 34. Flask-Assets: adding bundles assets.py: from flaskext.assets import Bundle def register_assets(assets): core = Bundle( 'js/src/core/jquery.js', 'js/src/core/underscore.js', filters='yui_js', output='js/bundle/core.js' ) assets.register('core', core)
  • 35. Flask-Assets: adding bundles ... app = Bundle( 'js/src/app/*.js', filters='yui_js', output='js/bundle/app.js' ) assets.register('app', app)
  • 37. Flask-Assets: how to use Somewhere in your template code: {% assets "core" %} <script src="{{ ASSET_URL }}"></script> {% endassets %} {% assets "app" %} <script src="{{ ASSET_URL }}"></script> {% endassets %}
  • 38. Flask-Assets: debug mode Flask-Assets generate code below (debug mode): <script src="/static/js/src/core/jquery.js"></ script> <script src="/static/js/src/core/underscore.js"></ script> <script src="/static/js/src/app/module1.js"></ script> <script src="/static/js/src/app/module2.js"></ script>
  • 39. Flask-Assets: production mode Flask-Assets generate code below (production mode): <script src="/static/js/bundles/core.js"></script> <script src="/static/js/bundles/app.js"></script> Static files was generated with Flask-Script command: maxk$ python manage.py assets rebuild
  • 40. More extensions: Flask-Mail Flask-Babel Flask-Cache Flask-csrf Flask-FlatPages Flask-lesscss ...
  • 41. Admin panel Flask-Admin Flask-Dashed
  • 42. Tests Unit, Behavior and JavaScript tests
  • 44. Testing: Unit & Behavior To test templates, views etc we need to have request context Before execution: self.app.test_request_context().push() After execution: self.app.test_request_context().pop()
  • 45. Behavior Testes with Lettuce Example feature and scenario: Feature: Auth Scenario: Sign In as featured expert When I go to "auth.login" view Then I see that response code is 200 And There's form with following fields: | form__username | | form__password | Fill the field "form__username" with "featured"
  • 46. lettuce-web Lettuce-web is a library which very close to headless testing using twill. lettuce-web doesn't require browser. You can write your features using lettuce-web predefined steps. More here: https://github.com/joymax/lettuce-web
  • 47. Flask-Jasmine Flask-Jasmine is extension to execute Jasmine JavaScript Tests More details https://github.com/joymax/flask-jasmine
  • 49. Issues What's going on in Flask world at the moment?
  • 50. Python 3 Status of porting Flask to Python 3 is unknown. Werkzeug not ported yet. Hopefully, will be ported to Python 3.3 ( PEP 414 for details)
  • 51. Werkzeug Werkzeug is really huge and have tons of tools. Flask based on Werkzeug. We all like Python for small, robust and clean libraries.
  • 53. That's all Questions? Source:  https://github.com/joymax/kyivpy-flask-in-details

Editor's Notes