首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏若城技术专栏

    【从零学习python 】87. 手动搭建HTTP服务器的Python实现及多线程并发处理

    multiprocessing import Process 我们导入了re模块用于正则表达式操作,socket模块用于网络通信,以及multiprocessing模块中的Process类用于创建子进程 定义WSGIServer 类 class WSGIServer(): def __init__(self, server, port, root): self.server = server target=self.handle_socket, args=(client_socket,)) p.start() client_socket.close() 在WSGIServer 主程序入口 if __name__ == '__main__': ip = '0.0.0.0' port = 8899 server = WSGIServer(ip, port, pages') print('server is running at {}:{}'.format(ip, port)) server.forever_run() 在主程序中,我们实例化了WSGIServer

    43211编辑于 2024-02-29
  • 来自专栏Python 学习

    day119-Flask的websocket使用

    import Flask, request from geventwebsocket.handler import WebSocketHandler from gevent.pywsgi import WSGIServer nick_name, msg)) if __name__ == '__main__': # 跟实际的 app 的原型方式不一样 print('服务启动') http_service = WSGIServer import Flask, request from geventwebsocket.handler import WebSocketHandler from gevent.pywsgi import WSGIServer send_content) if __name__ == '__main__': # 跟实际的 app 的原型方式不一样 print('服务启动') http_service = WSGIServer

    90500发布于 2020-04-25
  • 来自专栏快乐学Python

    flask+gevent+uwsgi部署

    # app.run(debug=True, host='0.0.0.0', port=5000) # 原flask默认部署 gevent_server = gevent.pywsgi.WSGIServer 参考文献: gevent-monkey-patching gevent.WSGIServer使用

    2.6K20发布于 2019-06-27
  • 来自专栏python3

    Windows下nginx配置pytho

    /usr/bin/python # encoding : utf-8 from flup.server.fcgi import WSGIServer def myapp(environ, start_response \n'] if __name__ == '__main__': WSGIServer(myapp,bindAddress=('127.0.0.1',8008)).run() 在命令行中运行 python

    1.1K20发布于 2020-01-08
  • 来自专栏小白维基

    Django 笔记-1-从请求到响应

    细则: [启动->WSGI]通过任意方式启动 Django 创建 WSGIServer 类的实例 用户通过浏览器请求某个 Django 页面 [WSGI]Django WSGIServer 接收客户端( 无论通过哪种方式,启动一个项目时,都会做两件事: 创建一个 WSGIServer 类的实例,来接受用户的请求。 通过 runserver 命令运行 Django 项目,在启动时都会调用下面的 run 方法,创建一个 WSGIServer 的实例,之后再调用其 serve_forever() 方法启动服务。 WSGIServer run() 方法会创建 WSGIServer 实例,主要作用是接收客户端请求,将请求传递给WSGI Application,然后将 WSGI Application 返回的 response WSGIRequestHandler 由 WSGIServer 在调用 handle_request 时创建实例,传入 request,cient_address,WSGIServer 三个参数,__init

    1.5K21编辑于 2022-04-02
  • 来自专栏python3

    django源码分析 python ma

    self.server_cls) except socket.error as e: ... run方法中选择了启动的解释器,最后都是通过inner_run中的run方法来执行,会启动一个WSGIServerWSGIServer需要一个回调函数handler(或者application),来执行django视图里面代码。 至此,django项目服务器启动流程完毕,接下来就是这个简单的WSGIServer,接受请求,解析请求参数,将请求参数传递给回调函数handler(或者application),handler根据参数执行相应的代码 ,返回数据给WSGIServerWSGIServer最终将数据返回给浏览器。

    67810发布于 2020-01-17
  • 来自专栏从零开始学自动化测试

    postman使用教程18-如何取出返回 cookie 中的 sessionId 值

    password":"123456"} 接口返回的token在返回body中可以获取到 HTTP/1.1 200 OK Date: Thu, 21 Oct 2021 13:55:01 GMT Server: WSGIServer sessionId").value console.log(sessionId); console 输出结果 取出返回头部 headers 中的值 如果取出的值,仅仅是返回头部的,如下:Server: WSGIServer

    4.6K30发布于 2021-11-05
  • 来自专栏糖果的实验室

    vulnhub靶场系列-bulldog

    (ECDSA) |_ 256 2f:ba:d5:e5:9f:a2:43:e5:3b:24:2c:10:c2:0a:da:66 (ED25519) 80/tcp open http WSGIServer 0.1 (Python 2.7.12) |_http-server-header: WSGIServer/0.1 Python/2.7.12 |_http-title: Bulldog Industries 8080/tcp open http WSGIServer 0.1 (Python 2.7.12) |_http-server-header: WSGIServer/0.1 Python/

    88110发布于 2019-11-20
  • 来自专栏Python程序员杂谈

    webpy 源码分析概览图

    这时执行到了httpserver.py的runsimple这个函数中,在此函数中,首先是调用WSGIServer这个函数生成一个server实例,然后在启动这个server。 在WSGIServer中主要工作是实例化wsgiserver包中的 CherryPyWSGIServer 这个类。顺着图再往下看 CherryPyWSGIServer 是继承自HTTPServer的。 wsgiserver/__init__.py 在CherryPyWSGIServer初始化是会创建一个self.requests的线程池,这个线程池在初始化时会持有这个CherryPyWSGIServer

    90830发布于 2019-03-01
  • 来自专栏从零开始学自动化测试

    python笔记42-http请求命令行工具(httpie)

    OPTIONS Content-Length: 290 Content-Type: application/json Date: Wed, 18 Sep 2019 14:21:25 GMT Server: WSGIServer OPTIONS Content-Length: 95 Content-Type: application/json Date: Wed, 18 Sep 2019 14:22:22 GMT Server: WSGIServer OPTIONS Content-Length: 95 Content-Type: application/json Date: Wed, 18 Sep 2019 14:46:36 GMT Server: WSGIServer

    73930发布于 2019-09-24
  • 来自专栏菲宇

    gunicorn简介、架构、安装与配置

    上面代码中的server_class实际上是一个gevent的WSGI SERVER的子类: class PyWSGIServer(pywsgi.WSGIServer): base_env = WSGI SERVER 真正等待链接和处理链接的操作是在gevent的WSGIServer 和 WSGIHandler中进行的。 最后再来看一下gevent的WSGIServer 和 WSGIHandler的主要实现: WSGIServer 的start函数里面调用start_accepting来处理到来的链接。 _handle, *args) 可以看出,WSGIServer 实际上是创建一个协程去处理该套接字,也就是说在WSGIServer 中,一个协程单独负责一个HTTP链接。协程中运行的self.

    4.8K20发布于 2019-06-12
  • 来自专栏从零开始学自动化测试

    httprunner学习3-extract提取token值参数关联

    OPTIONS Content-Length: 58 Content-Type: application/json Date: Sat, 21 Sep 2019 14:06:15 GMT Server: WSGIServer OPTIONS Content-Length: 109 Content-Type: application/json Date: Sat, 21 Sep 2019 15:37:06 GMT Server: WSGIServer OPTIONS Content-Length: 96 Content-Type: application/json Date: Sat, 21 Sep 2019 16:04:25 GMT Server: WSGIServer

    2.1K40发布于 2019-09-24
  • 来自专栏折腾折腾再折腾

    多进程web动态服务器

    p.start() cli_socket.close() self.tcp_server.close() def main(): wsgiserver = server() wsgiserver.run_server() if __name__ == "__main__": main() 现在我们返回的数据都是静态的,也就是说写好的, p.start() cli_socket.close() self.tcp_server.close() def main(): wsgiserver = server() wsgiserver.run_server() if __name__ == "__main__": main() 此时在浏览器中输入127.0.0.1:7891 = server() wsgiserver.run_server() if __name__ == "__main__": main() 这样只要在浏览器输出以.py结尾的就会返回

    4K20发布于 2019-09-23
  • 来自专栏个人总结系列

    开源AIGC学习—文生图模型服务封装

    result} api.add_resource(TextToImag, '/api/text2imag') if __name__ == '__main__': server = pywsgi.WSGIServer jpeg') api.add_resource(TextToImag, '/api/text2imag') if __name__ == '__main__': server = pywsgi.WSGIServer

    70910编辑于 2024-03-15
  • 来自专栏从零开始学自动化测试

    httprunner 3.x学习19 - 从返回头部headers取值

    ======== status_code : 200 headers : { "Date": "Tue, 17 Aug 2021 10:54:10 GMT", "Server": "WSGIServer headers.Content-Type data: {'status_code': 200, 'headers': {'Date': 'Tue, 17 Aug 2021 10:54:10 GMT', 'Server': 'WSGIServer

    1.3K31发布于 2021-08-20
  • 来自专栏侯哥的Python分享

    python网络-动态Web服务器案例(30)

    Daynamic.py #coding=utf-8 import socket import sys from multiprocessing import Process import re class WSGIServer serverHeaders = [ ('Date', 'Tue, 31 Mar 2016 10:11:12 GMT'), ('Server', 'WSGIServer /wsgiPy' def makeServer(serverAddr, application): server = WSGIServer(serverAddr) server.setApp application = getattr(module, application) httpd = makeServer(serverAddr, application) print('WSGIServer

    1.6K30发布于 2019-06-26
  • 来自专栏从零开始学自动化测试

    httprunner 3.x学习4 - 测试用例参数关联(export)

    OPTIONS Content-Length: 58 Content-Type: application/json Date: Sat, 21 Sep 2019 14:06:15 GMT Server: WSGIServer OPTIONS Content-Length: 109 Content-Type: application/json Date: Sat, 21 Sep 2019 15:37:06 GMT Server: WSGIServer OPTIONS Content-Length: 96 Content-Type: application/json Date: Sat, 21 Sep 2019 16:04:25 GMT Server: WSGIServer

    1.5K10发布于 2021-06-24
  • 来自专栏测试游记

    测试开发进阶(二十四)

    200 OK Content-Length: 650 Content-Type: application/json Date: Fri, 11 Oct 2019 13:02:56 GMT Server: WSGIServer 200 OK Content-Length: 202 Content-Type: application/json Date: Fri, 11 Oct 2019 13:31:46 GMT Server: WSGIServer 200 OK Content-Length: 145 Content-Type: application/json Date: Fri, 11 Oct 2019 13:42:44 GMT Server: WSGIServer Created Content-Length: 208 Content-Type: application/json Date: Fri, 11 Oct 2019 13:53:49 GMT Server: WSGIServer Content Content-Length: 2 Content-Type: application/json Date: Fri, 11 Oct 2019 14:03:45 GMT Server: WSGIServer

    1.4K50发布于 2019-10-15
  • 来自专栏python3

    Python Web开发中的WSGI协议

    core/servers/basehttp.py文件: def run(addr, port, wsgi_handler, ipv6=False, threading=False, server_cls=WSGIServer ): server_address = (addr, port) if threading: httpd_cls = type('WSGIServer', (socketserver.ThreadingMixIn : httpd.daemon_threads = True httpd.set_app(wsgi_handler) httpd.serve_forever()  实现的WSGIServer ,继承自wsgiref: class WSGIServer(simple_server.WSGIServer): """BaseHTTPServer that implements the Python

    1.2K10发布于 2020-01-16
  • 来自专栏从零开始学自动化测试

    python测试开发django-73.django视图 CBV 和 FBV

    200 OK Content-Length: 55 Content-Type: application/json Date: Sat, 23 Nov 2019 06:26:58 GMT Server: WSGIServer next=/fbvdemo/ Server: WSGIServer/0.2 CPython/3.6.0 Vary: Origin, Cookie X-Frame-Options: SAMEORIGIN

    75610发布于 2019-12-05
领券