In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Python how to achieve WEB, the article is very detailed, has a certain reference value, interested friends must read it!
Python implements the WEB test environment:
Server configuration: 4 x Intel (R) Xeon (R) CPU E5405 @ 2.00GHz, 4G memory, operating system: CentOS 5.3 x 86 / 64
Nginx front end + 4 tornado (0.2) web process
Tornado: http://www.tornadoweb.org (has been walled)
Python implements the WEB test scenario:
Http get request. Server returns "hello world" directly.
Python implements WEB code and nginx configuration:
Main.py: #! / usr/bin/python #-*-coding: utf-8-*-"" web main "" from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop from tornado.web import RequestHandler, Application, authenticated # from rockps.auth import AuthHandler class MainHandler (RequestHandler): def get (self): self.write ("hello world") settings = {} application = Application ([(r "/", MainHandler),] * * settings) if _ _ name__ = "_ _ main__": http_server = HTTPServer (application) http_server.listen (8081) IOLoop.instance () .start () nginx.conf: user root Worker_processes 1; error_log / var/nginx_error.log; pid / var/run/nginx.pid; events {worker_connections 51200; use epoll;} http {# Enumerate all the Tornado servers here upstream frontends {server 127.0.0.1 var/run/nginx.pid; events 8081; server 127.0.0.1 VR 8082; server 127.0.1 VR 8083; server 127.0.0.1 var/nginx_error.log; pid 8084;} # include / etc/nginx/mime.types; default_type application/octet-stream Access_log / var/log/nginx/access22.log; keepalive_timeout 65; proxy_read_timeout 200; sendfile on; tcp_nopush on; tcp_nodelay on; gzip on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/html text/css text/xml application/x-javascript application/xml application/atom+xml text/javascript # Only retry if there was a communication error, not a timeout # on the Tornado server (to avoid propagating "queries of death" # to all frontends) proxy_next_upstream error; server {listen 8085; # Allow file uploads client_max_body_size 50M; location ^ ~ / static/ {root / var/www; if ($query_string) {expires max;}} location = / favicon.ico {rewrite (. *) / static/favicon.ico } location = / robots.txt {rewrite (. *) / static/robots.txt;} location / {proxy_pass_header Server; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_pass http://frontends;} these are all the contents of the article "how Python implements WEB". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.