Ebook Foundations of python network progra2ming (3rd edition): Part 1

Part 2 book "Foundations of python network programmin" includes content: HTTP servers, the world wide web, building and parsing E-Mail, SMTP, POP, IMAP, telnet and SSH, FTP, RPC. | Chapter 10 HTTP Servers How can a Python program run as a server responding to HTTP requests In Chapter 7 you learned several basic socket and concurrency patterns for writing a TCP-based network server. With HTTP it is unlikely that you will ever need to write anything that low-level because the protocol s popularity has resulted in off-the-shelf solutions for all of the major server patterns that you might need. While this chapter will focus on third-party tools the Standard Library does have an HTTP server implementation built in. It can even be invoked from the command line. python3 -m Serving HTTP on port 8000 . This server follows the old conventions established in the 1990s for serving up files from the filesystem. The path in the HTTP request is translated into a path to search in the local filesystem. The server is designed to serve files only at or beneath its current working directory. Files are served normally. When a directory is named the server returns either the content of its file if one exists or a dynamically generated listing of the files inside. Having a small web server available wherever Python is installed has gotten me out of more than one awkward fix over the years when I have needed to transfer files between machines and none of the more specific file transfer protocols have been available. But what are the steps to take if you need something more if you need to put your own software in charge of responding to HTTP requests This book tackles this question in two separate chapters. This chapter will look at server architecture and deployment answering the questions that need solutions whether your code returns documents or a programmer- facing API. Chapter 11 will then describe the World Wide Web and it will examine tools specific to returning HTML pages and interacting with a user s browser. WSGI In the earliest days of HTTP programming many Python services were written as simple CGI scripts that were .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.