You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/pages/04-web-development/01-web-frameworks.markdown
+41-32Lines changed: 41 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,16 @@ meta: Find out about Python web frameworks, which are code libraries that solve
8
8
9
9
10
10
# Web frameworks
11
-
A web framework is a code library that makes a developer's life easier when
12
-
building reliable, scalable and maintainable web applications.
11
+
A web framework is a code library that makes
12
+
[web development](/web-development.html) faster and easier by providing
13
+
common patterns for building reliable, scalable and maintainable web
14
+
applications. After the early 2000s, professional web development projects
15
+
always use an existing web framework except in very unusual situations.
13
16
17
+
<imgsrc="/img/visuals/web-frameworks.jpg"width="100%"alt="Django, Bottle, Flask, Pyramid, Falcon and Sanic logos, copyright their respective owners."class="shot rnd outl">
14
18
15
-
## Why are web frameworks useful?
19
+
20
+
### Why are web frameworks useful?
16
21
Web frameworks encapsulate what developers have learned over the past twenty
17
22
years while programming sites and applications for the web. Frameworks make
18
23
it easier to reuse code for common HTTP operations and to structure projects
@@ -22,16 +27,21 @@ maintain the application.
22
27
<divclass="well see-also">Web frameworks are a concept implemented by <ahref="/django.html">Django</a>, <ahref="/flask.html">Flask</a>, <ahref="/bottle.html">Bottle</a>, <ahref="/pyramid.html">Pyramid</a>, <ahref="/morepath.html">Morepath</a> and <ahref="/other-web-frameworks.html">several other libraries</a>. Learn how the parts fit together in the <ahref="/web-development.html">web development</a> chapter or view <ahref="/table-of-contents.html">all topics</a>.</div>
23
28
24
29
25
-
## Common web framework functionality
30
+
###Common web framework functionality
26
31
Frameworks provide functionality in their code or through extensions to
27
32
perform common operations required to run web applications. These common
28
33
operations include:
29
34
30
35
1. URL routing
31
-
2. HTML, XML, JSON, and other output format templating
32
-
3. Database manipulation
33
-
4. Security against Cross-site request forgery (CSRF) and other attacks
34
-
5. Session storage and retrieval
36
+
1. Input form handling and validation
37
+
1.[HTML](/hypertext-markup-language-html.html), XML, JSON, and other output
38
+
formats with a [templating engine](/template-engines.html)
39
+
1. Database connection configuration and persistent data manipulation through
40
+
an [object-relational mapper (ORM)](/object-relational-mappers-orms.html)
41
+
1.[Web security](/web-application-security.html) against
42
+
Cross-site request forgery (CSRF), SQL Injection,
43
+
Cross-site Scripting (XSS) and other common malicious attacks
44
+
1. Session storage and retrieval
35
45
36
46
Not all web frameworks include code for all of the above functionality.
37
47
Frameworks fall on the spectrum from executing a single use case to providing
@@ -40,11 +50,13 @@ the "batteries-included" approach where everything possible comes bundled
40
50
with the framework while others have a minimal core package that is amenable
41
51
to extensions provided by other packages.
42
52
43
-
For example, the [Django web application framework](/django.html) includes an
44
-
Object-Relational Mapping (ORM) layer that abstracts relational database
45
-
read, write, query, and delete operations. However, Django's ORM
46
-
cannot work without significant modification on non-relational databases
47
-
such as [MongoDB](http://www.mongodb.org/).
53
+
For example, the [Django web application framework](/django.html) includes
54
+
[the Django ORM](/django-orm.html) layer that allows a deveoper to write
55
+
[relational database](/databases.html)
56
+
read, write, query, and delete operations in Python code rather than SQL.
57
+
However, Django's ORM cannot work without significant modification on
58
+
[non-relational (NoSQL) databases](/no-sql-datastore.html) such as
59
+
[MongoDB](/mongodb.html) or [Cassandra](/cassandra.html).
48
60
49
61
Some other web frameworks such as [Flask](/flask.html) and
50
62
[Pyramid](/pyramid.html) are easier to
@@ -53,23 +65,8 @@ There is a spectrum between minimal functionality with easy extensibility on
53
65
one end and including everything in the framework with tight integration on
54
66
the other end.
55
67
56
-
## Comparing web frameworks
57
-
Are you curious about how the code in a Django project is structured compared
58
-
with Flask? Check out
59
-
[this Django web application tutorial](https://www.twilio.com/docs/howto/walkthrough/appointment-reminders/python/django)
60
-
and then view [the same application built with Flask](https://www.twilio.com/docs/howto/walkthrough/appointment-reminders/python/flask).
<divclass="well see-also">While you're learning about web frameworks you should also study <ahref="/deployment.html">web application deployment</a> and <ahref="/application-programming-interfaces.html">web APIs</a>.</div>
70
-
71
68
72
-
## Do I have to use a web framework?
69
+
###Do I have to use a web framework?
73
70
Whether or not you use a web framework in your project depends on your
74
71
experience with web development and what you're trying to accomplish. If you
75
72
are a beginner programmer and just want to work on a web application as a
@@ -93,7 +90,20 @@ Using a web framework to build a web application certainly isn't required,
93
90
but it'll make most developers' lives easier in many cases.
94
91
95
92
96
-
## Web framework resources
93
+
### Comparing web frameworks
94
+
Are you curious about how the code in a Django project is structured compared
95
+
with Flask? Check out
96
+
[this Django web application tutorial](https://www.twilio.com/docs/sms/tutorials/appointment-reminders-python-django)
97
+
and then view [the same application built with Flask](https://www.twilio.com/docs/sms/tutorials/appointment-reminders-python-flask).
0 commit comments