20170831 基于wsgi的web简易框架

.wiz-code-container { position: relative; padding: 8px 0; margin: 5px 25px 5px 5px; text-indent: 0 }
.CodeMirror { font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; color: black; font-size: 0.83rem }
.CodeMirror-lines { padding: 4px 0 }
.CodeMirror pre { padding: 0 4px }
.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler { background-color: white }
.CodeMirror-gutters { border-right: 1px solid #ddd; background-color: #f7f7f7; white-space: nowrap }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0 3px 0 5px; min-width: 20px; text-align: right; color: #999; white-space: nowrap }
.CodeMirror-guttermarker { color: black }
.CodeMirror-guttermarker-subtle { color: #999 }
.CodeMirror-cursor { border-left: 1px solid black; border-right: none; width: 0 }
.CodeMirror div.CodeMirror-secondarycursor { border-left: 1px solid silver }
.cm-fat-cursor .CodeMirror-cursor { width: auto; border: 0 !important; background: #7e7 }
.cm-fat-cursor div.CodeMirror-cursors { z-index: 1 }
.cm-animate-fat-cursor { width: auto; border: 0; background-color: #7e7 }
.CodeMirror-overwrite .CodeMirror-cursor { }
.cm-tab { display: inline-block; text-decoration: inherit }
.CodeMirror-rulers { position: absolute; left: 0; right: 0; top: -50px; bottom: -20px; overflow: hidden }
.CodeMirror-ruler { border-left: 1px solid #ccc; top: 0; bottom: 0; position: absolute }
.cm-s-default .cm-header { color: blue }
.cm-s-default .cm-quote { color: #090 }
.cm-negative { color: #d44 }
.cm-positive { color: #292 }
.cm-header,.cm-strong { font-weight: bold }
.cm-em { font-style: italic }
.cm-link { text-decoration: underline }
.cm-strikethrough { text-decoration: line-through }
.cm-s-default .cm-keyword { color: #708 }
.cm-s-default .cm-atom { color: #219 }
.cm-s-default .cm-number { color: #164 }
.cm-s-default .cm-def { color: #00f }
.cm-s-default .cm-variable,.cm-s-default .cm-punctuation,.cm-s-default .cm-property,.cm-s-default .cm-operator { }
.cm-s-default .cm-variable-2 { color: #05a }
.cm-s-default .cm-variable-3 { color: #085 }
.cm-s-default .cm-comment { color: #a50 }
.cm-s-default .cm-string { color: #a11 }
.cm-s-default .cm-string-2 { color: #f50 }
.cm-s-default .cm-meta { color: #555 }
.cm-s-default .cm-qualifier { color: #555 }
.cm-s-default .cm-builtin { color: #30a }
.cm-s-default .cm-bracket { color: #997 }
.cm-s-default .cm-tag { color: #170 }
.cm-s-default .cm-attribute { color: #00c }
.cm-s-default .cm-hr { color: #999 }
.cm-s-default .cm-link { color: #00c }
.cm-s-default .cm-error { color: #f00 }
.cm-invalidchar { color: #f00 }
.CodeMirror-composing { border-bottom: 2px solid }
div.CodeMirror span.CodeMirror-matchingbracket { color: #0f0 }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: #f22 }
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3) }
.CodeMirror-activeline-background { background: #e8f2ff }
.CodeMirror { position: relative; background: #f5f5f5 }
.CodeMirror-scroll { overflow: hidden !important; margin-bottom: 0; margin-right: 0; padding: 10px 0 16px; outline: none; position: relative }
.CodeMirror-sizer { position: relative; border-right: 30px solid transparent }
.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none }
.CodeMirror-vscrollbar { right: 0; top: 0 }
.CodeMirror-hscrollbar { bottom: 0; left: 0 !important }
.CodeMirror-scrollbar-filler { right: 0; bottom: 0 }
.CodeMirror-gutter-filler { left: 0; bottom: 0 }
.CodeMirror-gutters { position: absolute; left: 0; top: -5px; min-height: 100%; z-index: 3 }
.CodeMirror-gutter { white-space: normal; height: inherit; display: inline-block; vertical-align: top; margin-bottom: -30px }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: none !important; border: none !important }
.CodeMirror-gutter-background { position: absolute; top: 0; bottom: 0; z-index: 4 }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; text-align: center }
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines { cursor: text; min-height: 1px }
.CodeMirror pre { border-width: 0; background: transparent; font-family: inherit; font-size: inherit; margin: 0; white-space: pre; line-height: inherit; color: inherit; z-index: 2; position: relative; overflow: visible }
.CodeMirror-wrap pre { white-space: pre-wrap }
.CodeMirror-linebackground { position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 0 }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto }
.CodeMirror-widget { }
.CodeMirror-rtl pre { direction: rtl }
.CodeMirror-code { outline: none }
.CodeMirror-scroll,.CodeMirror-sizer,.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber { }
.CodeMirror-measure { position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden }
.CodeMirror-cursor { position: absolute }
.CodeMirror-measure pre { position: static }
div.CodeMirror-cursors { visibility: hidden; position: relative; z-index: 3 }
div.CodeMirror-dragcursors { visibility: visible }
.CodeMirror-focused div.CodeMirror-cursors { visibility: visible }
.CodeMirror-selected { background: #d9d9d9 }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0 }
.CodeMirror-crosshair { cursor: crosshair }
.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection { background: #d7d4f0 }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0 }
.cm-searching { background: rgba(255, 255, 0, .4) }
.cm-force-border { padding-right: .1px }
.cm-tab-wrap-hack::after { content: "" }
span.CodeMirror-selectedtext { background: none }
.CodeMirror-activeline-background,.CodeMirror-selected { }
.CodeMirror-blur .CodeMirror-activeline-background,.CodeMirror-blur .CodeMirror-selected { visibility: hidden }
.CodeMirror-blur .CodeMirror-matchingbracket { color: inherit !important; outline: none !important; text-decoration: none !important }
.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8 }
.cm-s-blackboard div.CodeMirror-selected { background: #253B76 }
.cm-s-blackboard .CodeMirror-line::selection,.cm-s-blackboard .CodeMirror-line>span::selection,.cm-s-blackboard .CodeMirror-line>span>span::selection { background: rgba(37, 59, 118, .99) }
.cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99) }
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0 }
.cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D }
.cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888 }
.cm-s-blackboard .CodeMirror-linenumber { color: #888 }
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 }
.cm-s-blackboard .cm-keyword { color: #FBDE2D }
.cm-s-blackboard .cm-atom { color: #D8FA3C }
.cm-s-blackboard .cm-number { color: #D8FA3C }
.cm-s-blackboard .cm-def { color: #8DA6CE }
.cm-s-blackboard .cm-variable { color: #FF6400 }
.cm-s-blackboard .cm-operator { color: #FBDE2D }
.cm-s-blackboard .cm-comment { color: #AEAEAE }
.cm-s-blackboard .cm-string { color: #61CE3C }
.cm-s-blackboard .cm-string-2 { color: #61CE3C }
.cm-s-blackboard .cm-meta { color: #D8FA3C }
.cm-s-blackboard .cm-builtin { color: #8DA6CE }
.cm-s-blackboard .cm-tag { color: #8DA6CE }
.cm-s-blackboard .cm-attribute { color: #8DA6CE }
.cm-s-blackboard .cm-header { color: #FF6400 }
.cm-s-blackboard .cm-hr { color: #AEAEAE }
.cm-s-blackboard .cm-link { color: #8DA6CE }
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8 }
.cm-s-blackboard .CodeMirror-activeline-background { background: #3C3636 }
.cm-s-blackboard .CodeMirror-matchingbracket { outline: 1px solid grey; color: white !important }
html,body { font-size: 12pt }
body { font-family: Helvetica, "Hiragino Sans GB", "微软雅黑", "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 1.6; margin: 0 auto; padding: 1.25rem 1rem }
h1,h2,h3,h4,h5,h6 { margin: 1.25rem 0 0.625rem; padding: 0; font-weight: bold }
h1 { font-size: 1.67rem }
h2 { font-size: 1.5rem }
h3 { font-size: 1.25rem }
h4 { font-size: 1.17rem }
h5 { font-size: 1rem }
h6 { font-size: 1rem; color: #777777; margin: 1rem 0 }
div,p,ul,ol,dl,li { margin: 0 }
blockquote,table,pre,code { margin: 8px 0 }
ul,ol { padding-left: 2rem }
ol.wiz-list-level1>li { list-style-type: decimal }
ol.wiz-list-level2>li { list-style-type: lower-latin }
ol.wiz-list-level3>li { list-style-type: lower-roman }
blockquote { padding: 0 0.75rem }
blockquote>:first-child { margin-top: 0 }
blockquote>:last-child { margin-bottom: 0 }
img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0 }
table { border-collapse: collapse; border: 1px solid #bbbbbb }
td,th { padding: 4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb; min-height: 28px }
.wiz-hide { display: none !important }

Request    翻译为请求

Response    翻译为响应

from wsgiref.simple_server import make_server

def application(environ, start_response):
# 通过environ封装成一个所有请求信息的对象
# start_response可以很方便的设置响应头
start_response(‘200 OK‘, [(‘Content-Type‘, ‘text/html‘)])
return [b"<h1>hello world</h1>"]

# 封装了socket对象以及准备过程(bind, listen)
httpd = make_server(‘‘, 8080, application)

print(‘Serving HTTP on port 8080...‘)
# 开始监听HTTP请求:
httpd.serve_forever()<wiz_code_mirror>

x

16

1

from wsgiref.simple_server import make_server

2


3


4

def application(environ, start_response):

5

    # 通过environ封装成一个所有请求信息的对象

6

    # start_response可以很方便的设置响应头

7

    start_response(‘200 OK‘, [(‘Content-Type‘, ‘text/html‘)])

8

    return [b"<h1>hello world</h1>"]

9


10


11

# 封装了socket对象以及准备过程(bind, listen)

12

httpd = make_server(‘‘, 8080, application)

13


14

print(‘Serving HTTP on port 8080...‘)

15

# 开始监听HTTP请求:

16

httpd.serve_forever()
时间: 2024-10-11 21:05:34

20170831 基于wsgi的web简易框架的相关文章

SPWebServer:一个基于 SPServer 的 web 服务器框架

SPWebServer:一个基于 SPServer 的 web 服务器框架 博客分类: OpenSource项目 应用服务器框架Web网络应用多线程 看到这个题目,估计很多人会问:为什么要再实现一个 web 服务器? 这里有几个原因: 1.这是一个 web 服务器框架,不是一个完整的 web 服务器.也就是说 SPWebServer 提供的是一套 API 和类库,可以方便地集成到现有的应用程序中.可以称 SPWebServer 为 embedded web server . 2.有些时候,我们需

基于Selenium的web自动化框架

1 什么是selenium Selenium 是一个基于浏览器的自动化工具,它提供了一种跨平台.跨浏览器的端到端的web自动化解决方案.Selenium主要包括三部分:Selenium IDE.Selenium WebDriver 和Selenium Grid: Selenium IDE:Firefox的一个扩展,它可以进行录制回放,并可以把录制的操作以多种语言(例如java,python等)的形式导出成测试用例. Selenium WebDriver:提供Web自动化所需的API,主要用作浏览

20170901 基于wsgi的web框架二

.wiz-code-container { position: relative; padding: 8px 0; margin: 5px 25px 5px 5px; text-indent: 0 } .CodeMirror { font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; color: black; font-size: 0.83rem } .CodeMirror-lines { paddin

python web简易框架体验

———————— ————data #保存class类及类中的对象 ————int #执行程序 ———————————— #@Time:2020/2/4 16:48 #@Author :jok #@file :data.py #@software:PyCharm class web: def home(self): return "首页" def list(self): return "列表" def a_404(self): return "404&qu

基于Ruby的Watir-WebDriver自动化测试框架

Watir-WebDriver       —— 软件测试的自动化时代 QQ群:160409929 支持哪些浏览器? 几乎所有的浏览器: 比如Firefox, Chrome 和IE,除了Safari. 支持网页上哪些元素? watir-webdriver支持所有的HTML元素 运行模式是什么? Watir-WebDriver是基于ruby开发web驱动框架 自动化测试框架 根据不同业务开发相应自动化用例,由Ruby测试框架统一调用分析展示.实现出入口统一,工具类封装:降低用例开发复杂度,框架统一

Web.py 框架学习笔记 - URL处理

最近由于工作需要开始学习基于python的web应用框架web.py.为了方便学习,将学习心得逐日记下以便日后复习. URL 模板: web.py提供了一套url处理的模板,在python工程中,只需要将网页结构配置为一个元组(tuple)即可.该元组在web.py中的解析模式为:url路径,对应处理url的类名.这里,类名必须和service代码中对应的类名一致.例如, 1 urls = ( 2 "/tasks/?", "signin", 3 "/tas

Python实现简易HTTP服务器与MINI WEB框架(利用WSGI实现服务器与框架解耦)

本文描述如果简单实现自定义Web服务器与自定义简易框架,并且不断进行版本迭代,从而清晰的展现服务器与Web框架之间是如何结合.如何配合工作的.以及WSGI是什么. 一.选取一个自定义的服务器版本 参照 https://www.cnblogs.com/leokale-zz/p/11957768.html 中的各种服务器实现版本,我们选择比较简单的多进程版本作为演示版本. 代码如下: import socket import re import multiprocessing def handle_

基于Extjs的web表单设计器 第六节——界面框架设计

基于Extjs的web表单设计器 基于Extjs的web表单设计器 第一节 基于Extjs的web表单设计器 第二节——表单控件设计 基于Extjs的web表单设计器 第三节——控件拖放 基于Extjs的web表单设计器 第四节——控件拖放 基于Extjs的web表单设计器 第五节——数据库设计 基于Extjs的web表单设计器 第六节——界面框架设计 基于Extjs的web表单设计器 第七节——取数公式设计 基于Extjs的web表单设计器 第八节——表单引擎设计 这一节我给大家介绍一下表单设

002 web基础之手动实现简易web服务框架

目录 一.软件开发架构 二.实现一个简单的web服务 2.1 S端修正版本 2.2 S端将html标签返回 2.3 浏览器携带参数访问S端时的处理 2.4 S端返回html页面给浏览器 2.5 减少代码冗余的server端 三.基于wsgrief模块实现简易web服务框架 3.1 通过后端获取当前时间展示到前端 3.2 后端通过获取数据库的信息,展示到前端页面 一.软件开发架构 C/S 客户端 服务端 B/S 浏览器和服务端 注意:B/S 的本质也是C/S架构 二.实现一个简单的web服务 我们