Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python [TechWeek #1 WebDev Day]

Python [TechWeek #1 WebDev Day]

Presentation by Oleg Shidlovsky at TeamsPark TechWeek.

Avatar for TeamsPark

TeamsPark

March 23, 2015

More Decks by TeamsPark

Other Decks in Programming

Transcript

  1. from kivy.app import App from kivy.uix.button import Button class TestApp(App):

    def build(self): return Button(text='Hello World') TestApp().run() Kivy
  2. The web framework for perfectionists with deadlines. Ridiculously fast. Django

    was designed to help developers take applications from concept to completion as quickly as possible. Reassuringly secure. Django takes security seriously and helps developers avoid many common security mistakes. Exceedingly scalable. Some of the busiest sites on the Web leverage Django’s ability to quickly and flexibly scale.
  3. $ django-admin.py startproject mysite $ python manage.py migrate $ python

    manage.py runserver 3 steps to conquer the world
  4. my_project my_app_1 models.py views.py urls.py my_app_2 models.py views.py urls.py templates

    index.html statics style.css manage.py settings.py django file architecture
  5. Django Features - Template generator - ORM - Signals -

    Unittest - Cache - EmailBackend - Migrations - Compatibility with celery - Forms - User Authentication
  6. Django ORM Object-relational Mapper class Blog(models.Model): headline = models.CharField(max_length=255) body_text

    = models.TextField() pub_date = models.DateField() authors = models.ManyToManyField(Author) b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.') b.save() Blog.objects.filter(pub_date__year=2006) Blog.objects.filter(headline__startswith="What") Blog.objects.order_by('headline')
  7. Flask example from flask import Flask app = Flask(__name__) @app.route('/')

    def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run()
  8. The Pylons Project was founded by the people behind the

    Pylons web framework to develop web application framework technology in Python. Rather than focusing on a single web framework, the Pylons Project will develop a collection of related technologies. The first package is the Pyramid web framework.
  9. Celery Distributed Task Queue from celery import Celery app =

    Celery('tasks', broker='amqp://guest@localhost//') @app.task def add(x, y): return x + y Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.
  10. Speed https://www.techempower.com/benchmarks/ Framework Best performance cpoll_cppsp 1,057,793 Gemini 914,749 Go

    348,55 Nodejs 228,887 Wsgi 220,602 php 180,147 Falcon 171,773 http-listener 108,543 Tornado 87,708 Flask 60,065 Django 12,082 rails-ruby 6,09