wsgiref — WSGI Utilities and Reference Implementation nginx
from wsgiref.util import setup_testing_defaults, request_uri
from wsgiref.simple_server import make_server # A relatively simple WSGI application. It's going to print out the
# environment dictionary after being updated by setup_testing_defaults
def simple_app(environ, start_response):
setup_testing_defaults(environ) status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')] start_response(status, headers)
r_uri = request_uri(environ, include_query=True)
if 'test_dump' in r_uri:
return [("%s: %s\n" % (key, value)).encode('utf-8') for key, value in environ.items()]
elif 'uid' in r_uri: try:
uid = int(r_uri.split('/')[-1])
if uid > 0:
r_l = gen_r(uid)
return [("%s: %s\n" % (i, r_l[i])).encode('utf-8') for i in range(len(r_l))]
else:
return [('%s%s' % ('BAD-REQUEST ', r_uri)).encode('utf-8')]
except Exception as e:
return [('%s%s%s' % (e, ' retry...,please.... ', r_uri)).encode('utf-8')]
else:
return [('%s%s' % ('dev-ING- ', r_uri)).encode('utf-8')] with make_server('', 8000, simple_app) as httpd:
print("Serving on port 8000...")
httpd.serve_forever()
wsgiref — WSGI Utilities and Reference Implementation nginx的更多相关文章
- Hibernate Validator 6.0.9.Final - JSR 380 Reference Implementation: Reference Guide
Preface Validating data is a common task that occurs throughout all application layers, from the pre ...
- django自带wsgi server vs 部署uwsgi+nginx后的性能对比
一.下面先交代一下测试云主机 cpu: root@alexknight:/tmp/webbench-1.5# cat /proc/cpuinfo |grep model model : model n ...
- python常用函数 库 转
可能经常用到的标准模块和第三方常用的50个库 本文由python培训班授课老师整理 数学计算: numbers - Numeric abstract base classes math ...
- Python教程大纲
缘起:最近想在部门推Python语言,写这个blog主要就是个教程大纲,之前先列出一些资源:Python历史:http://www.docin.com/p-53019548.html ...
- #######【Python】【基础知识】【标准库】目录及学习规划 ######
下述参考Python DOC https://docs.python.org/zh-cn/3/library/index.html 概述 可用性注释 内置函数 内置常量 由 site 模块添加的常量 ...
- The Python Standard Library
The Python Standard Library¶ While The Python Language Reference describes the exact syntax and sema ...
- nginx,wsgi,flask之间的关系
之前看写flask 应用的一些疑问,百度上的答案解释的不错,这里记着以后可以看看Web 服务器层对于传统的客户端 - 服务器架构,客户端向服务器发送请求,服务器接收请求,处理请求,最后给客户端返回请求 ...
- 如何理解Nginx, WSGI, Flask之间的关系
概览 之前对 Nginx,WSGI(或者 uWSGI,uwsgi),Flask(或者 Django),这几者的关系一存存在疑惑.通过查阅了些资料,总算把它们的关系理清了. 总括来说,客户端从发送一个 ...
- 如何理解Nginx, WSGI, Flask(Django)之间的关系
如何理解Nginx, WSGI, Flask(Django)之间的关系 值得指出的是,WSGI 是一种协议,需要区分几个相近的名词: uwsgi 同 wsgi 一样也是一种协议,uWSGI服务器正是使 ...
随机推荐
- 第三天,小作业,表达式,while循环
num += 1 等价于 num = num + 1num -= 1 等价于 num = num - 1num *= 2 等价于 num = num * 2num /= 2 等价于 num = num ...
- 大数据学习——装私服nexus
(一)安装 解压之后 进入bin文件夹下 复制路径 D:\software\nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin 进入命令行窗口输入以下命令,安装成功 ...
- 什么是Istio
本文主要是对Istio Prelim 1.0(https://preliminary.istio.io/docs/)的翻译 Istio:一种开放式平台,用于连接,管理和保护微服务. Istio提供了一 ...
- OSPF选路原则
1:O路由>Oia路由>external路由! O:计算LSA-1和LSA-2,前提age不能MaxAge,metric不能LSinfinity,计算出来的最小metric的路由放入RIB ...
- spoj 839 最小割+二进制
#include<stdio.h> #include<string.h> #include<queue> using namespace std; #define ...
- CodeForces - 586D Phillip and Trains
这道题是一道搜索题 但是 如果没有读懂或者 或者拐过弯 就很麻烦 最多26个火车 那么每一个周期 (人走一次 车走一次) 就要更改地图 的状态 而且操作复杂 容易超时 出错 利用相对运动 计周期为 人 ...
- UOJ 58 (树上带修改的莫队)
UOJ 58 糖果公园 Problem : 给一棵n个点的树,每个点上有一种颜色,对于一条路径上的点,若 i 颜色第 j 次出现对该路径权值的贡献为 w[i] * c[j], 每次询问一条路径的权值, ...
- poj2243+poj1915骑士问题
2243是骑士问题,八个格子的,BFS,因为要最短路经,所以没有用A*,A*跑不出来,太慢了,因为要搜索到所有解啊!一直更新最优,而BFS,一层一层搜索,第一次得到的便是最短的了!300格子,标记的话 ...
- linux日志服务器审计客户端history记录
https://blog.csdn.net/yanggd1987/article/details/70255179
- 安装mysql时出现应用程序无法正常启动(0xc000007b)、初始化失败以及密码忘记怎样重置?
https://blog.csdn.net/zztingfeng/article/details/80155624