KEMBAR78
Python for web development | PPTX
Python for Web Dev
Luis Borbon
16/September/2016
Agenda
1. Python language
2. Python Chain
3. Web frameworks
4. The basics
5. Questions
6. References
1. Python Language
Python is a high-level, structured, open-
source programming language that can
be used for a wide variety of
programming tasks.
Python was created by Guido Van
Rossum in the early 1990s.
1.1. Python Features
● Simple
● Easy to Learn
● Free and Open Source
● High-level Language
● Portable
● Interpreted
● Object Oriented
1.2. The Zen of Python
● Beautiful is better than ugly.
● Explicit is better than implicit.
● Simple is better than complex.
● In the face of ambiguity, refuse the temptation
to guess.
● Now is better than never.
● If the implementation is easy to explain, it may
be a good idea.
1.3. Popularity of Coding Languages
Source: codeeval.com
Source: PopularitY
Source: codingdojo.com
1.4. Python on the Academy
1.5. Speed Benchmarking
Source: Udemy
2. Python Chain
Development
● django
● flask
DevOps
● Ansible
● Fabric
● Salt
● AWS Lambda
Analytics
● Numpy
● SciPy
● Pandas
● Scikit Learn
● Jupyter
3. Web Frameworks
● URL routing
● HTML, XML, JSON, and other output format
templating
● Database manipulation
● Security against Cross-site request forgery
(CSRF) and other attacks
● Session storage and retrieval
3.1. On Production
YouTube
Yahoo Maps
SurveyMonkey
Google
Bitly
Reddit
Bitbucket
Instagram
NASA
Firefox
Prezi
Evenbrite
Pinterest
Instagram
Spotify
Rdio
Disqus
Washington Post
3.2. Popular Web Frameworks
● Django
○ Bitbucket, Pinterest, Instagram, and
The Onion
● Pyramid
○ Dropbox, Fedora
● Flask
3.3. Web Frameworks Comparison
● Django is best for:
○ Developers who aim to include all the batteries a web application will need.
○ Developers who wants to use ORM, templating, routing, authentication, database administration
and bootstrapping on the go
● Pyramid is best for:
○ Developers working on API projects
○ Prototyping a concept
○ Developing large web applications, such as a CMS
● Flask is best for:
○ Developers who care about best practices
○ Developers who want to prototype something quickly
○ Developers who need a standalone app
4. The Basics
$ python
>>> print("Hello World!")
Hello World!
On this link https://python.swaroopch.com/basics.html check:
● Indentation
● Control Flow
● Functions
4.1. Simple web framework example
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
django-admin startproject hello_django
django-admin startapp howdy
hello_django
├── hello_django
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── howdy
│ ├── admin.py
│ ├── migrations
│ ├── models.py
│ ├── tests.py
│ └── views.py
└── manage.py
Flask django
$ pip install Flask
$ python app.py
* Running on http://localhost:5000/
5. Questions
6. References
Python popular languages
http://blog.codeeval.com/codeevalblog/2016/2/2/most-popular-coding-languages-of-2016
Python web frameworks
https://www.airpair.com/python/posts/django-flask-pyramid
PHP, Python and Ruby comparison
https://blog.udemy.com/wp-content/uploads/2012/01/PROGRAMMING-LANGUAGE-3.png

Python for web development

  • 1.
    Python for WebDev Luis Borbon 16/September/2016
  • 2.
    Agenda 1. Python language 2.Python Chain 3. Web frameworks 4. The basics 5. Questions 6. References
  • 3.
    1. Python Language Pythonis a high-level, structured, open- source programming language that can be used for a wide variety of programming tasks. Python was created by Guido Van Rossum in the early 1990s.
  • 4.
    1.1. Python Features ●Simple ● Easy to Learn ● Free and Open Source ● High-level Language ● Portable ● Interpreted ● Object Oriented
  • 5.
    1.2. The Zenof Python ● Beautiful is better than ugly. ● Explicit is better than implicit. ● Simple is better than complex. ● In the face of ambiguity, refuse the temptation to guess. ● Now is better than never. ● If the implementation is easy to explain, it may be a good idea.
  • 6.
    1.3. Popularity ofCoding Languages Source: codeeval.com Source: PopularitY Source: codingdojo.com
  • 7.
    1.4. Python onthe Academy
  • 8.
  • 9.
    2. Python Chain Development ●django ● flask DevOps ● Ansible ● Fabric ● Salt ● AWS Lambda Analytics ● Numpy ● SciPy ● Pandas ● Scikit Learn ● Jupyter
  • 10.
    3. Web Frameworks ●URL routing ● HTML, XML, JSON, and other output format templating ● Database manipulation ● Security against Cross-site request forgery (CSRF) and other attacks ● Session storage and retrieval
  • 11.
    3.1. On Production YouTube YahooMaps SurveyMonkey Google Bitly Reddit Bitbucket Instagram NASA Firefox Prezi Evenbrite Pinterest Instagram Spotify Rdio Disqus Washington Post
  • 12.
    3.2. Popular WebFrameworks ● Django ○ Bitbucket, Pinterest, Instagram, and The Onion ● Pyramid ○ Dropbox, Fedora ● Flask
  • 13.
    3.3. Web FrameworksComparison ● Django is best for: ○ Developers who aim to include all the batteries a web application will need. ○ Developers who wants to use ORM, templating, routing, authentication, database administration and bootstrapping on the go ● Pyramid is best for: ○ Developers working on API projects ○ Prototyping a concept ○ Developing large web applications, such as a CMS ● Flask is best for: ○ Developers who care about best practices ○ Developers who want to prototype something quickly ○ Developers who need a standalone app
  • 14.
    4. The Basics $python >>> print("Hello World!") Hello World! On this link https://python.swaroopch.com/basics.html check: ● Indentation ● Control Flow ● Functions
  • 15.
    4.1. Simple webframework example from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run() django-admin startproject hello_django django-admin startapp howdy hello_django ├── hello_django │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── howdy │ ├── admin.py │ ├── migrations │ ├── models.py │ ├── tests.py │ └── views.py └── manage.py Flask django $ pip install Flask $ python app.py * Running on http://localhost:5000/
  • 16.
  • 17.
    6. References Python popularlanguages http://blog.codeeval.com/codeevalblog/2016/2/2/most-popular-coding-languages-of-2016 Python web frameworks https://www.airpair.com/python/posts/django-flask-pyramid PHP, Python and Ruby comparison https://blog.udemy.com/wp-content/uploads/2012/01/PROGRAMMING-LANGUAGE-3.png

Editor's Notes

  • #5 Simple Python is a simple and minimalistic language. Reading a good Python program feels almost like reading English, although very strict English! This pseudo-code nature of Python is one of its greatest strengths. It allows you to concentrate on the solution to the problem rather than the language itself. Easy to Learn As you will see, Python is extremely easy to get started with. Python has an extraordinarily simple syntax, as already mentioned. Free and Open Source Python is an example of a FLOSS (Free/Libré and Open Source Software). In simple terms, you can freely distribute copies of this software, read its source code, make changes to it, and use pieces of it in new free programs. FLOSS is based on the concept of a community which shares knowledge. This is one of the reasons why Python is so good - it has been created and is constantly improved by a community who just want to see a better Python. High-level Language When you write programs in Python, you never need to bother about the low-level details such as managing the memory used by your program, etc. Portable Due to its open-source nature, Python has been ported to (i.e. changed to make it work on) many platforms. All your Python programs can work on any of these platforms without requiring any changes at all if you are careful enough to avoid any system-dependent features. You can use Python on GNU/Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2, Amiga, AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion, Acorn RISC OS, VxWorks, PlayStation, Sharp Zaurus, Windows CE and PocketPC! You can even use a platform like Kivy to create games for your computer and for iPhone, iPad, and Android. Interpreted This requires a bit of explanation. A program written in a compiled language like C or C++ is converted from the source language i.e. C or C++ into a language that is spoken by your computer (binary code i.e. 0s and 1s) using a compiler with various flags and options. When you run the program, the linker/loader software copies the program from hard disk to memory and starts running it. Python, on the other hand, does not need compilation to binary. You just run the program directly from the source code. Internally, Python converts the source code into an intermediate form called bytecodes and then translates this into the native language of your computer and then runs it. All this, actually, makes using Python much easier since you don't have to worry about compiling the program, making sure that the proper libraries are linked and loaded, etc. This also makes your Python programs much more portable, since you can just copy your Python program onto another computer and it just works! Object Oriented Python supports procedure-oriented programming as well as object-oriented programming. In procedure-oriented languages, the program is built around procedures or functions which are nothing but reusable pieces of programs. In object-oriented languages, the program is built around objects which combine data and functionality. Python has a very powerful but simplistic way of doing OOP, especially when compared to big languages like C++ or Java. Extensible If you need a critical piece of code to run very fast or want to have some piece of algorithm not to be open, you can code that part of your program in C or C++ and then use it from your Python program. Embeddable You can embed Python within your C/C++ programs to give scripting capabilities for your program's users. Extensive Libraries The Python Standard Library is huge indeed. It can help you do various things involving regular expressions,documentation generation, unit testing, threading, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files, cryptography, GUI (graphical user interfaces), and other system-dependent stuff. Remember, all this is always available wherever Python is installed. This is called the Batteries Included philosophy of Python. Besides the standard library, there are various other high-quality libraries which you can find at the Python Package Index.
  • #6 >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
  • #15 https://bitbucket.org/minergroup/devops/src/fe7299116627ce80e047bd9ce1d634f0685a5159/lambda/functions/demo-provision/main.py?at=master&fileviewer=file-view-default
  • #16 More information: https://www.airpair.com/python/posts/django-flask-pyramid