What exactly do Django and Flask Frameworks do?

Issue related to: Web Application

Module used: BeautifulSoup, Requests

Issue link: https://www.reddit.com/r/learnpython/comments/g0zqgv/web_development_with_python/

Issue:

I’m fluent with Python and am learning HTML and CSS right now. I want to integrate Python with HTML and CSS to create web apps. I know there are Django and Flask Frameworks, but what exactly do they do? What do they accomplish for me? What’s the difference between using Python or PHP?

Thanks!

Explanation:

Three questions are being asked here:

The first question is “What exactly do web frameworks such as Django and Flask do?”

Web frameworks make it a easier for you to build up web applications by providing functions such as

  • authentication and authorization of users
  • storage of data in a database
  • managing changes to the database with migrations
  • and routing

which almost all web apps need.

Examples of web applications that you might be aware of

  • YouTube
  • Dropbox
  • Spotify
  • Instagram

The second question is “What do web frameworks accomplish for me?”

The web frameworks extend the capabilities of Python. It will allow you to use your Python skills in addition to your skills in HTML,CSS and JavaScript. Some advantages that may be of interest to you are:

  • It will allow you to execute Python code inside of your HTML file. For example you might want to repeat a sentence such as “Hello world” 100 times on your page, instead of writing <p> Hello world </p> 100 times you can instead write it once and use a python for loop to achieve the same result which will save you time.
  • You may have noticed when making several pages for a website you are repeating several lines of HTML on every page such as the Title, a link to CSS and JS. With a web framework you can create a master page (base page) with all the content that will be repeated, any subsequent pages will extend this template so will also have this added to their page. This will make managing and updating pages in the future is easier.
  • Unlike JavaScript which is client side, web frameworks are server side so code can not be seen by the user. This makes your application more secure on the web.

The third question is “What’s the difference between using Python or PHP?”

Their is not much difference between Python and PHP. It mostly comes down to how familiar you are with both languages.

A reason you might decide to use Python is the library capabilities