服务器端网站编程

动态网站 - 服务器端编程主题是一系列模块,展示如何创建动态网站;响应 HTTP 请求而提供定制信息的网站。这些模块提供了服务器端编程的一般介绍,以及有关如何使用 Django (Python) 和 Express (Node.js/JavaScript) Web 框架创建基本应用的特定初学者指南。

¥The Dynamic WebsitesServer-side programming topic is a series of modules that show how to create dynamic websites; websites that deliver customized information in response to HTTP requests. The modules provide a general introduction to server-side programming, along with specific beginner-level guides on how to use the Django (Python) and Express (Node.js/JavaScript) web frameworks to create basic applications.

大多数主要网站都使用某种服务器端技术来根据需要动态显示数据。例如,想象一下亚马逊上有多少种产品,想象一下 Facebook 上有多少帖子。使用不同的静态页面显示所有这些内容效率极低,因此此类网站会显示静态模板(使用 HTMLCSSJavaScript 构建),然后在需要时动态更新这些模板内显示的数据,例如当你想要 在亚马逊上查看不同的产品。

¥Most major websites use some kind of server-side technology to dynamically display data as required. For example, imagine how many products are available on Amazon, and imagine how many posts have been written on Facebook. Displaying all of these using different static pages would be extremely inefficient, so instead such sites display static templates (built using HTML, CSS, and JavaScript), and then dynamically update the data displayed inside those templates when needed, such as when you want to view a different product on Amazon.

在现代 Web 开发世界中,强烈建议学习服务器端开发。

¥In the modern world of web development, learning about server-side development is highly recommended.

学习途径

¥Learning pathway

服务器端编程入门通常比客户端开发更容易,因为动态网站往往执行许多非常相似的操作(从数据库检索数据并将其显示在页面中,验证用户输入的数据并将其保存在 数据库、检查用户权限和登录用户等),并使用 Web 框架构建,使这些和其他常见的 Web 服务器操作变得容易。

¥Getting started with server-side programming is usually easier than client-side development, because dynamic websites tend to perform a lot of very similar operations (retrieving data from a database and displaying it in a page, validating user-entered data and saving it in a database, checking user permissions and logging users in, etc.), and are constructed using web frameworks that make these and other common web server operations easy.

编程概念(或特定编程语言)的基础知识很有用,但不是必需的。同样,不需要客户端编码方面的专业知识,但基本知识将帮助你更好地与创建客户端 Web "前端" 的开发者合作。

¥Basic knowledge of programming concepts (or of a particular programming language) is useful, but not essential. Similarly, expertise in client-side coding is not required, but a basic knowledge will help you work better with the developers creating your client-side web "front end".

你需要了解 "网络是如何运作的"。我们建议你首先阅读以下主题:

¥You will need to understand "how the web works". We recommend that you first read the following topics:

有了这些基本的了解,你就可以准备好完成本节中的模块了。

¥With that basic understanding, you'll be ready to work your way through the modules in this section.

模块

¥Modules

本主题包含以下模块。你应该从第一个模块开始,然后继续学习以下模块之一,这些模块展示了如何使用适当的 Web 框架来使用两种非常流行的服务器端语言。

¥This topic contains the following modules. You should start with the first module, then go on to one of the following modules, which show how to work with two very popular server-side languages using appropriate web frameworks.

服务器端网站编程第一步

该模块提供有关服务器端网站编程(例如 "它是什么?"、"它与客户端编程有何不同?" 和 "为什么它有用?")的与技术无关的信息。本模块还概述了一些更流行的服务器端 Web 框架,并提供有关如何为你的网站选择最佳框架的指导。最后,介绍了 Web 服务器安全性。

Django Web 框架 (Python)

Django 是一个非常流行且功能齐全的服务器端 Web 框架,用 Python 编写。该模块解释了为什么 Django 是一个如此优秀的 Web 服务器框架、如何设置开发环境以及如何使用它执行常见任务。

Express Web 框架 (Node.js/JavaScript)

Express 是一种流行的 Web 框架,用 JavaScript 编写并托管在 Node.js 运行时环境中。该模块解释了该框架的一些主要优点、如何设置开发环境以及如何执行常见的 Web 开发和部署任务。

也可以看看

¥See also

无框架节点服务器

本文为那些不想使用框架的人提供了一个使用纯 Node.js 构建的简单静态文件服务器。

正确配置服务器 MIME 类型

配置服务器以将正确的 MIME types(也称为媒体类型或内容类型)发送到浏览器对于浏览器能够正确处理和显示内容非常重要。防止恶意内容伪装成良性内容也很重要。