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服务器正是使 ...
随机推荐
- 前端基础之CSS_2
摘要 盒子模型 浮动 清除 溢出 定位 模态框 rgba 与 opacity透明区别 一.CCS盒子模型 margin:标签与标签之间的距离,主要用于控制标签周围间的间隔,从视觉上达到相互分开的目的 ...
- Haybale Stacking(差分数组 + 求中位数的一些方法 + nth_element)
题意: 给定N个初始值为0的数, 然后给定K个区间修改(区间[l,r] 每个元素加一), 求修改后序列的中位数. 分析: K个离线的区间修改可以使用差分数组(http://www.cnblogs.co ...
- POJ-2773 Happy 2006,暴力2700ms+水过!
Happy 2006 这个题很可能会超时的,但我几乎暴力的方法2700ms+过了,可能是后台水 ...
- NYOJ27水池数目,类似于FZU1008最大黑区域,简单搜索题~~~
水池数目 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 南阳理工学院校园里有一些小河和一些湖泊,现在,我们把它们通一看成水池,假设有一张我们学校的某处的地图,这个地图上 ...
- 洛谷P1432 倒水问题
题目背景 In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with th ...
- [APIO2012] 派遣 dispatching
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 4580 Solved: 2348 Description 在一个忍者的帮派里,一些忍者们被选中派遣给 ...
- Flume+kakfa+sparkStream实时处理数据测试
flume:从数据源拉取数据 kafka:主要起到缓冲从flume拉取多了的数据 sparkStream:对数据进行处理 一.flume拉取数据 1.源数据文件读取配置 在flume目录的 ...
- msp430项目编程17
msp430中项目---红外遥控系统 1.定时器工作原理 2.电路原理说明 3.代码(显示部分) 4.代码(功能实现) 5.项目总结 msp430项目编程 msp430入门学习
- ACM-ICPC 2018 焦作赛区网络预赛 H、L
https://nanti.jisuanke.com/t/31721 题意 n个位置 有几个限制相邻的三个怎么怎么样,直接从3开始 矩阵快速幂进行递推就可以了 #include <bits/st ...
- QT程序--CS1.6文件整理及安装器
这是一个在高二的时候写的一个QT程序,当时对于QT也不算是特别熟悉吧,算是我第一个QT程序,当时由于CS1.6的文件安装的繁琐,又有一些服务器的管理的麻烦操作,对CS的服务器管理一直都很麻烦,当时高二 ...