How the Web Works

2023-12-27 15:09
文章标签 web works

本文主要是介绍How the Web Works,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Learn Python The Hard Way 书中的相关内容,抄了一遍。
又是一本不可多得的好书。

去年寒假,就是今年一月份,打印了这本书,学了一部分。
三月份在院楼机房花了三星期,大概看完了这本书。
半年后的现在,再看一遍,依然有好多收获。
真的,不用特意寻找特别多的学习资源,好好利用现有的资源。
真的能学好三、两本书。找份工作,没问题的。


I’m start with a simple diagram that shows you the different parts of a web request and how the information flows:

这里写图片描述

I’ve labeled the lines with letters so I can walk you through a regular request process:

  1. You type in the url http://learnpythonthehardway.org/ into your browser and it sends the request out on line (A) to your computer’s network interface.
  2. Your request goes out over the Internet on line (B) and then to the remote computer on line (C) where my server accepts the request.
  3. Once my computer accepts it, my web application get it, and my Python code runs the index.GET handler.
  4. The response comes out of my Python server when I return it, and get back to your browser over line (D) again.
  5. The server running this site takes the response off line (D) then send it back over the Internet on line (C).
  6. The response from the server then comes off the Internet on line (B) , and your computer’s network interface hands it to your browser on line (A).
  7. Finally, your browser then displays the response.

In this description there are a few tems you should know so that you have a common vocabulary to work with when talking about your web application:

Browser
The software that you’re probably using every day. Most people don’t know what it really does, they just call it “the internet”. It’s job is to take addresses (like http://learnpythonthehardway.org ) you type into the URL bar, then use that information to make requests to the server at that address.

Address
This is normally a URL (Uniform Resource Locator) like http://learnpythonthehardway.org/ and indicates where a browser should go. The first part http indicates the protocol you want to use, in this case “Hyper-Text Transport Protocol”. You can also try ftp://ibiblio.org/ to see how “File Transport Protocol” works. The learnpythonthehardway.org part is the “hostname”, ot a human readable address you can remember and which maps to a number called an IP address, similar to a telephone number for a computer on the Internet. Finally, URLs can have a trailing path like the /book/ part of http://learnpythonthehardway.org/book/ which indicates a file or some resource on the server to retrieve with a request. There are many other parts, but those are the main ones.

Connection
Once a browser knows that protocol you want to use (http), what server you want to talk to (learnpythonthehardway.org), and what resource on the server to get, it must take a conection. The browser simply asks your Operating System (OS) to open a “port” to the computer, ususlly port 80. When it works the OS hands back to your program something that works like a file, but is actually sending and receiving bytes over the network wires between your computer and the other computer at “learnpythonthehardway.org”. This is also the same thing that happens with http://localhost:8000/ but in this case you’re telling the browser to connect to your own computer (localhost) and use port 8080 rather than the default of 80. You could also do http://learnpythonthehardway.org:80/ and get the same result, except you’re explicitly saying to use port 80 instead of letting it be that by default.

Request
Your browser is connected using the address you gave. Now it needs to ask for the resource it wants (or you want) on the remote server. If you gave /book/ at the end of the URL, then youwant the file (resource) at /book/, and most servers will use the real file /book/index.html but pretend it doesn’t exist. What the browser does to get this resource is send a request to the server. I won’t get into exactly how it does this, but just understand that it has to send something to query the server for the request. The interesting thing is that these “resources” don’t have to be files. For instance, when the browser in your application asks for something, the server is returning something your Python code generated.

Server
The server is the computer at the end of a browser’s connection that knows how to answer your browser’s requests for files/resources. Most web servers just send files, and that’s actually the majority of traffic. But you’re actually building a server in Python that knows how to take requests for resource, and then return strings that you craft using Python. When you do this crafting, you can pretending to be a file to the browser, but really it’s just code. As you can see from Ex50, it also doesn’t take much code to create a response.

Response
This is the HTML (css, javascript, or images) your server wants to send back to the browser as the answer to the browser’s request. In the case of files, it just reads them off the disk and sends them to the browser, but it wraps the cintents of the disk in a special “header” so the browser knows what it’s getting. In the case of your application, you’re still sending then same thing, including the header, but you generate that data on the fly with your Python code.

这篇关于How the Web Works的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/543542

相关文章

Java Web指的是什么

Java Web指的是使用Java技术进行Web开发的一种方式。Java在Web开发领域有着广泛的应用,主要通过Java EE(Enterprise Edition)平台来实现。  主要特点和技术包括: 1. Servlets和JSP:     Servlets 是Java编写的服务器端程序,用于处理客户端请求和生成动态网页内容。     JSP(JavaServer Pages)

BUUCTF靶场[web][极客大挑战 2019]Http、[HCTF 2018]admin

目录   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 [web][HCTF 2018]admin 考点:弱密码字典爆破 四种方法:   [web][极客大挑战 2019]Http 考点:Referer协议、UA协议、X-Forwarded-For协议 访问环境 老规矩,我们先查看源代码

EasyPlayer.js网页H5 Web js播放器能力合集

最近遇到一个需求,要求做一款播放器,发现能力上跟EasyPlayer.js基本一致,满足要求: 需求 功性能 分类 需求描述 功能 预览 分屏模式 单分屏(单屏/全屏) 多分屏(2*2) 多分屏(3*3) 多分屏(4*4) 播放控制 播放(单个或全部) 暂停(暂停时展示最后一帧画面) 停止(单个或全部) 声音控制(开关/音量调节) 主辅码流切换 辅助功能 屏

9.8javaweb项目总结

1.主界面用户信息显示 登录成功后,将用户信息存储在记录在 localStorage中,然后进入界面之前通过js来渲染主界面 存储用户信息 将用户信息渲染在主界面上,并且头像设置跳转,到个人资料界面 这里数据库中还没有设置相关信息 2.模糊查找 检测输入框是否有变更,有的话调用方法,进行查找 发送检测请求,然后接收的时候设置最多显示四个类似的搜索结果

JavaWeb【day09】--(Mybatis)

1. Mybatis基础操作 学习完mybatis入门后,我们继续学习mybatis基础操作。 1.1 需求 需求说明: 根据资料中提供的《tlias智能学习辅助系统》页面原型及需求,完成员工管理的需求开发。 通过分析以上的页面原型和需求,我们确定了功能列表: 查询 根据主键ID查询 条件查询 新增 更新 删除 根据主键ID删除 根据主键ID批量删除

利用Django框架快速构建Web应用:从零到上线

随着互联网的发展,Web应用的需求日益增长,而Django作为一个高级的Python Web框架,以其强大的功能和灵活的架构,成为了众多开发者的选择。本文将指导你如何从零开始使用Django框架构建一个简单的Web应用,并将其部署到线上,让世界看到你的作品。 Django简介 Django是由Adrian Holovaty和Simon Willison于2005年开发的一个开源框架,旨在简

web群集--nginx配置文件location匹配符的优先级顺序详解及验证

文章目录 前言优先级顺序优先级顺序(详解)1. 精确匹配(Exact Match)2. 正则表达式匹配(Regex Match)3. 前缀匹配(Prefix Match) 匹配规则的综合应用验证优先级 前言 location的作用 在 NGINX 中,location 指令用于定义如何处理特定的请求 URI。由于网站往往需要不同的处理方式来适应各种请求,NGINX 提供了多种匹

构建高性能WEB之HTTP首部优化

0x00 前言 在讨论浏览器优化之前,首先我们先分析下从客户端发起一个HTTP请求到用户接收到响应之间,都发生了什么?知己知彼,才能百战不殆。这也是作为一个WEB开发者,为什么一定要深入学习TCP/IP等网络知识。 0x01 到底发生什么了? 当用户发起一个HTTP请求时,首先客户端将与服务端之间建立TCP连接,成功建立连接后,服务端将对请求进行处理,并对客户端做出响应,响应内容一般包括响应

(javaweb)mysql---DDL

一.数据模型,数据库操作 1.二维表:有行有列 2. 3.客户端连接数据库,发送sql语句给DBMS(数据库管理系统),DBMS创建--以文件夹显示 二.表结构操作--创建 database和schema含义一样。 这样就显示出了之前的内容。

云原生之高性能web服务器学习(持续更新中)

高性能web服务器 1 Web服务器的基础介绍1.1 Web服务介绍1.1.1 Apache介绍1.1.2 Nginx-高性能的 Web 服务端 2 Nginx架构与安装2.1 Nginx概述2.1.1 Nginx 功能介绍2.1.2 基础特性2.1.3 Web 服务相关的功能 2.2 Nginx 架构和进程2.2.1 架构2.2.2 Ngnix进程结构 2.3 Nginx 模块介绍2.4