一个简单的ip测试服务器

打印返回 请求头request

import socket

def send_data(conn, data=None, status=200):
if status != 200 and data is None:
data = '响应失败'
try:
conn.sendall(bytes(f"HTTP/1.1 {status} OK\r\n\r\n", "utf-8")) # 响应头
conn.sendall(bytes(f"{data}", "utf-8"))
except:
return 0
return 1 def runserver(addr='127.0.0.1', port=7999, back_log=10, buffer_size=1024):
webserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip_prot = (addr, port)
webserver.bind(ip_prot)
webserver.listen(back_log) print('web服务启动: ', ip_prot) while True:
conn, addr = webserver.accept()
recvdata = conn.recv(buffer_size) index_text = recvdata.decode()
print('请求ip', addr) send_data(conn, data=index_text) conn.close() if __name__ == '__main__': runserver(addr='0.0.0.0')

Dome_iptest_server的更多相关文章

随机推荐

  1. sql03

    1.约束 约束详解 ->约束的目的:保证数据的完整性. not null ->默认值约束.可空约束.主键约束.外键约束.唯一键约束.检查约束 1) 用sql语句为表添加新的字段 2) 为字 ...

  2. yolo3各部分代码详解(超详细)

    0.摘要 最近一段时间在学习yolo3,看了很多博客,理解了一些理论知识,但是学起来还是有些吃力,之后看了源码,才有了更进一步的理解.在这里,我不在赘述网络方面的代码,网络方面的代码比较容易理解,下面 ...

  3. chrome 和 chromeDriver

    在写selenium的时候,发现很简单的case也报错 package com.lv.test; import org.junit.Test; import org.openqa.selenium.W ...

  4. Web Scraper 高级用法——利用正则表达式筛选文本信息 | 简易数据分析 17

    这是简易数据分析系列的第 17 篇文章. 学习了这么多课,我想大家已经发现了,web scraper 主要是用来爬取文本信息的. 在爬取的过程中,我们经常会遇到一个问题:网页上的数据比较脏,我们只需要 ...

  5. 标题 发布状态 评论数 阅读数 操作 操作 CNN目标检测系列算法发展脉络简析——学习笔记(三):Fast R-CNN

    最近两周忙着上网课.投简历,博客没什么时间写,姑且把之前做的笔记放上来把... 下面是我之前看论文时记的笔记,之间copy上来了,内容是Fast R-CNN的,以后如果抽不出时间写博客,就放笔记上来( ...

  6. XSS构造剖析

    参考:邱永华<XSS跨站脚本攻击剖析与防御> 一 绕过XSS-filter 1.利用<>标记注射Html/JavaScript比如:<script>alert('X ...

  7. A Systems-Level Characterization of the Differentiation of Human Embryonic Stem Cells into Mesenchymal Stem Cells (解读人:王欣然)

    文献名:A Systems-Level Characterization of the Differentiation of Human Embryonic Stem Cells into Mesen ...

  8. Mol Cell Proteomics. | Integration and analysis of CPTAC proteomics data in the context of cancer genomics in the cBioPortal (解读人:徐洪凯)

    文献名:Integration and analysis of CPTAC proteomics data in the context of cancer genomics in the cBioP ...

  9. 曹工说Spring Boot源码(24)-- Spring注解扫描的瑞士军刀,asm技术实战(上)

    写在前面的话 相关背景及资源: 曹工说Spring Boot源码(1)-- Bean Definition到底是什么,附spring思维导图分享 曹工说Spring Boot源码(2)-- Bean ...

  10. [IROS 2018]Semantic Mapping with Simultaneous Object Detection and Localization

      论文地址:https://arxiv.org/abs/1810.11525   论文视频:https://www.youtube.com/watch?v=W-6ViSlrrZg​www.youtu ...