首页 > 编程语言 >python2 http服务端和客户端

python2 http服务端和客户端

时间:2023-09-25 18:56:48浏览次数:42  
标签:http self py response import PORT 服务端 python2

server.py

import SimpleHTTPServer
import SocketServer
class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/plain')
        self.end_headers()
        self.wfile.write("hello")
PORT = 8000
handler = MyHandler
httpd = SocketServer.TCPServer(("", PORT), handler)
print "Serving at port", PORT
httpd.serve_forever()

client.py

import urllib2
url = 'http://10.1.1.100:8000'
response = urllib2.urlopen(url)
response_data = response.read()
print(response_data)

标签:http,self,py,response,import,PORT,服务端,python2
From: https://www.cnblogs.com/xwjh/p/17728610.html

相关文章

  • nginx: The plain HTTP request was sent to HTTPS port
    问题描述TheplainHTTPrequestwassenttoHTTPSport当访问用http时则报错。用https时不报错。检查配置:server{listen80ssl;server_namehngj.zxynyxxx.cn;ssl_certificate/usr/local/nginx/cert/hngj.zxynyxxx.cn.pem;ssl_certificate_key/usr......
  • C#中实现校验是否包含中文与http接口地址中解析ip和端口号
    场景Winform/CSharp中实现对Http接口地址、IP地址字符串格式/合法性校验:https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/129616161在上面的基础上对某http接口地址(ip加端口号,示例http://127.0.0.1:9092)进行校验是否包含中文以及解析该地址获取ip和端口号博客:h......
  • ES报错:[parent] Data too large, data for [<http_request>] would be larger than limi
    ES报错:[parent]Datatoolarge,datafor[<http_request>]wouldbelargerthanlimitofXXXX  当es这个错误的时候:[parent]Datatoolarge,datafor[<http_request>]wouldbelargerthanlimitof[23941899878/22.2gb],with{bytes_wanted=23941987633bytes_l......
  • ansible教程:使用win_shell和win_copy从 HTTP 文件服务器下载文件并将其复制到目标位置
    with_fileglob参数无法直接指定HTTP文件服务器上的文件路径。它是用于在本地文件系统中进行文件的模式匹配,并将匹配的文件作为迭代项来执行任务。如果你需要从HTTP文件服务器上下载文件并将其复制到目标位置,你可以使用适当的工具或库来实现这个任务。下面是一个示例,使用curl......
  • 无法在web.xml或使用此应用程序部署的jar文件中解析绝对uri:[http://java.sun.com/jsp/
    今天解决了一个很早之前的问题!!!无法在web.xml或使用此应用程序部署的jar文件中解析绝对uri:[http://java.sun.com/jsp/jstl/core]之前一直以为是jar包不匹配,但是改了jar包之后连uri都分辨不出来了后来在网上查到是tomcat的问题,将tomcat的conf目录下的catalina.properties的tomc......
  • 一、简易搭建本地CAS服务端
    CAS服务端war包下载https://repo1.maven.org/maven2/org/apereo/cas/cas-server-webapp-tomcat/5.3.14/可使用迅雷下载cas-server-webapp-tomcat-5.3.14.war,速度很快将wab包放到本地tomcat的webapps下D:\tomcat\apache-tomcat-8.5.63\webapps\cas\WEB-INF\classes\servic......
  • Http访问格式刨析
    *概念:HyperTextTransferProtocol超文本传输协议*传输协议:定义了,客户端和服务器端通信时,发送数据的格式 参考火狐浏览器,其它浏览器没找到*特点:1.基于TCP/IP的高级协议2.默认端口号:803.基于请求/响应模型的:一次请求对应一次响应4.无状态的:每次请求之间相互......
  • flask框架在Centos正常启动后到Windows浏览器访问(http://192.168.124.129:5550/)提示无
    1、flask在centos正常启动 2、然后复制链接到window访问,提示无法访问3、排查下,Linux和Windows互相ping下WindowpingLinuxIP LinuxpingWindowIP如上能够正常ping通,说明网段是正常的4、再排查下,Linux是不是防火墙没有关闭查看防火墙状态命令:systemctlstatusfir......
  • scheduler,kube-controller-manager 报server returned HTTP status 401 Unauthorized
    现象:K8S组件报serverreturnedHTTPstatus401Unauthorized,看apiserver 日志有很多Unabletoauthenticatetherequest"err="[x509:certificatehasexpiredorisnotyet 1、分析:是因为集群证书更新了,然而使用kubectldeletepods方式去重启组件是没生效的,需要通过......
  • 【转载https://www.cnblogs.com/niuben/p/12017242.html】Linux top命令详解
    Linuxtop命令详解转载出处:https://www.cnblogs.com/niuben/p/12017242.htmltop参数详解第一行,任务队列信息,同uptime命令的执行结果系统时间:07:27:05运行时间:up1:57min,当前登录用户:3user负载均衡(uptime)loadaverage:0.00,0.00,0.00average后面的三个数分......