Web applications can be made with Python. To create web applications, you need a Web Framework. A Web Framework is a module that makes web development much easier.

A web application is a program that answers requests over HTTP. You write the logic in Python, a web framework calls your code when somebody opens a page, and your code sends something back.

That is the whole idea. A framework is a set of libraries that saves you from handling sockets, headers and routing yourself.

The most popular Web Frameworks is: Django.

Backend - Web Frameworks

Which other web Frameworks exist?
There are more Web Framworks like Bottle, Pyramid and Morepath. You can also implement your Web Framework, but that’s like reinventing the wheel.

What is usually inside an Web Framework
A lot of code for creating web apps. A webframework contains all kind of functionality thats useful when creating a web app.

This includes the typical HTTP operations, database access, model-view-controller, URL router and many more:


FeatureUse
URL routingGiven a URL, execute the rightccode
Database Manipulation ToolsAn ORM or raw SQL.
FormattingHTML, JSON, XML output
Template EngineDisplays the data using templates
Session support
Security CSRF protection

Frontend

AngularJS and React
When creating your app, you may want to build an awesome frontend interface using AngularJS or React. This can be combined using an API on the Python side. They have a steep learning curve, but they are great modules.

Hosting

To put your web app online, you can use PythonAnywhere.
By using their Cloud, you don’t have to setup any servers manually. Its very easy for Python web hosting.

What sits inside a framework

  • URL routing: given a url, run this function.
  • Templating: put data into an html page.
  • Database access: an ORM or plain SQL.
  • Request and response objects: the headers, the cookies, the form data.
  • Session handling and security helpers, like CSRF protection.
  • A development server so you can test without setting up a real one.

The two big ones in Python are Flask and Django. Flask gives you the routing and the template engine and lets you pick everything else. Django gives you the whole project layout including an admin panel and a migration system, which saves a lot of work on a bigger site.

For a small API Flask is quicker. For a site with users, an admin and a database Django saves you from building those parts.

Reading helps, writing fixes it. PyChallenge has exercises on this and you can try them right now.