DOKK Library

Python for Web Development: A brief Introduction

Authors Josef Wachtler

License CC-BY-4.0 CC-BY-SA-4.0

Plaintext
Python for Web Development:
A brief Introduction


Josef Wachtler
March 23, 2021
Educational Technology, Graz University of Technology
Content




  Python Programming Language


  Flask: A Micro Web Framework


  Django Web Framework


  Conclusion




                                 1
Python Programming Language
Python Programming Language




    • interpreted
    • multi-paradigm programming language
        • object-oriented programming
        • structured programming
        • ...
    • dynamic typing
    • garbage collection




                                            2
Libraries




     • large standard library
            • database connection
            • GUI toolkit
            • ...
     • Python Package Index
            • third-party software repository
            • more than 290,000 packages (www.modulecounts.com)




                                                                  3
Connecting Python to Web Servers




    • Web Server Gateway Interface (WSGI)
        • nginx: uWSGI
        • apache: mod wsgi
        • ...
    • Asynchronous Server Gateway Interface (ASGI)




                                                     4
Flask: A Micro Web Framework
Flask: A Micro Web Framework




    • a microframework for web development initially released on
      April 1, 2010
    • github.com/pallets/flask
    • based on
        • Werkzeug: toolkit for WSGI
        • Jinja: template engine
    • implements nothing which is implemented by other libraries
    • extensions for database connection, form validation, ...




                                                                   5
Example



      from flask import Flask
      app = Flask ( __name__ )

      @app . route ( " / " )
      def index ():
           return " Python for Web Development "



      if __name__ == " __main__ " :
          app . run ( debug = False )



                                                   6
Django Web Framework
Django Web Framework




    • a framework for developing large and database-driven web
      applications initially released on July 21, 2005
    • www.djangoproject.com
    • Model-View-Controller architectural design pattern
    • includes libraries for many web-releated functionalities




                                                                 7
Features


    • object-relational mapper to bind python classes (models) to
      database tables
    • auto-generated admin interface based on the models
    • template engine (views)
    • explicit URL definition (controller)
    • form validation
    • internationalization
    • caching framework
    • web server for development
    • ...


                                                                    8
Conclusion
Conclusion




    • Python is an interpreted, multi-paradigm programming
      language with an extensive standard library and a huge
      repository for third-party libraries
    • Flask is a microframework for web development with
      extensions for many web-related functionalities
    • in contrast Django is a complex framework including a wide
      range of these functionalities




                                                                   9
Thank you! ;-)




                         Questions?
    • DI Dr. Josef Wachtler BSc
      Educational Technology, Graz University of Technology
    • josef.wachtler@tugraz.at
    • josefwachtler.wordpress.com
    • Slides: github.com/wachjose88/slides




                                                              10
Credits




   Slides created by Josef Wachtler josef.wachtler@tugraz.at and
   licensed under a Creative Commons Attribution 4.0 International
   (CC BY 4.0) License.

                                                    cb
   The theme itself is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License and can be

   downloaded at github.com/matze/mtheme. This does not affect the presentation created with the theme.




                                                                                                                       11