python

bottle framework

#!/usr/bin/python
# -*- coding utf-8 -*- from bottle import route, run, debug, request
#from cgi import escape @route('/hello', method='GET')
def hello():
name = request.GET.get('name')
if not name:
name = "This guy's unknow :("
return 'Hello {0}'.format(name) debug(True)
run(host='localhost', port=8080, reloader=True)

Now I add a route here which is the

'/hello'

and I define the method to be 'GET'

And the request has         request.GET.get('name')

then

name will be assigned again

All the def will return

return 'hello {0}'.format(name)

The reloader means the server will restart when it finds any files has been changed.

如果有注释掉前面的那句的话。

#from cgi import escape

可以出现下面的结果:

现在我们加上这个cgi的escape,目的是为了不让浏览器地址栏里的内容自动检索内容。

<h1></h1>标签

让我们大家来看看效果

看到了地址栏里面就没有继续在parse html代码了。

看看html代码内部的源码是:

非解析的html代码,这里曾经学习过php,跟这个比较相似。一样的道理。 &lt;     &gt;  标签。

And if the method is POST

check those codes out:

#!/usr/bin/python
# -*- coding utf-8 -*- from bottle import route, run, debug, request
#from cgi import escape @route('/hello', method='POST')
def hello():
name = request.POST.get('name')
if not name:
name = "This guy's unknow :("
return 'Hello {0}'.format(name) debug(True)
run(host='localhost', port=8080, reloader=True)

实际上POST与GET没有什么区别。

只是在判断上有区别,判断一下,post可以让服务器修改一些内容,如果是get的话,那就是向服务器取得内容。就这么简单。

Bottle GET method. Request的更多相关文章

  1. sencha touch Ext.Ajax.request 错误 Cannot call method 'request' of undefined 解决方案

    凡是Cannot call method '' of undefined 这类错误大部分都可以参照下面的办法来解决 在st中有时候你会发现使用Ext.Ajax.request会出现一下错误: Cann ...

  2. 使用bottle进行web开发(2):http request

    我们知道,http request有多个方法,比如get,post,delete,patch,put等.对用的,bottle都定义了相应的装饰器,目前定义了五个: get(),post(),put() ...

  3. Python自动化运维之29、Bottle框架

    Bottle 官网:http://bottlepy.org/docs/dev/index.html Bottle是一个快速.简洁.轻量级的基于WSIG的微型Web框架,此框架只由一个 .py 文件,除 ...

  4. Bottle 中文文档

    译者: smallfish (smallfish.xy@gmail.com) 更新日期: 2009-09-25 原文地址: http://bottle.paws.de/page/docs (已失效) ...

  5. Recipes — Bottle 0.13-dev documentation

    Recipes - Bottle 0.13-dev documentation Recipes¶ This is a collection of code snippets and examples ...

  6. 用Bottle开发web程序(一)

    Bottle Bottle是一个轻量级的web app框架.相较与django等框架,bottle几乎没有任何依赖,而且只有一个文件.而相对于python默认的SimpleHTTPServer,功能更 ...

  7. bottle源码

    import sys __author__ = 'Marcel Hellkamp' __version__ = '0.13-dev' __license__ = 'MIT' ############# ...

  8. bottle框架剖析

    bottle框架剖析 使用 源码分析 一.使用 大致有以下几部分 quick start request routing generate contents request Data template ...

  9. python之Bottle框架

    一.简单的Bottle框架 1)bottle框架简介 安装 pip install bottle Bottle是一个快速.简洁.轻量级的基于WSIG的微型Web框架. 此框架只由一个 .py 文件,除 ...

随机推荐

  1. 【转】关于“ORA-01653: 表 SYS.AUD$ 无法通过 128 (在表空间 SYSTEM 中) 扩展”的错误

    SQL*Plus: Release 11.1.0.6.0 - Production on 星期一 5月 17 18:31:08 2010 Copyright (c) 1982, 2007, Oracl ...

  2. oracle 数据库技术支持生命周期表

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl4b3Jh/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...

  3. EXCEL导入GridView,然后再汇入数据库.

    原文:EXCEL导入GridView,然后再汇入数据库. 近日项目中有一个多笔料号要输入,我做了一个用javascript复制输入框的功能,可以输入多笔料号. 但是使用者反馈,料号太多,可能几百个料号 ...

  4. hdu 4858 项目管理(STL集装箱)

    项目管理 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  5. 用持续集成工具Travis进行构建和部署

    用持续集成工具Travis进行构建和部署 用持续集成工具Travis进行构建和部署 摘要:本文简单说明了如何使用持续集成工具Travis进行构建和部署的过程. 1. 概述 持续集成(Continuou ...

  6. 开源的.Net ORM微型框架SuperHelper

    SuperHelper——灵活通用的.开源的.Net ORM微型框架 SuperHelper是博主利用业余时间编写的一个ORM微型框架,除了可以提高开发效率,与其它ORM框架相比,博主更加喜欢Supe ...

  7. Repository在DDD中的应用

    Repository在DDD中的应用2014-10-09 08:55 by Jesse Liu, 98 阅读, 0 评论, 收藏, 编辑 概述 上一篇我们算是粗略的介绍了一下DDD,我们提到了实体.值 ...

  8. POJ Big Christmas Tree(最短的基础)

    Big Christmas Tree 题目分析: 叫你构造一颗圣诞树,使得 (sum of weights of all descendant nodes) × (unit price of the ...

  9. Google Hacking的实现以及应用

    Google Hacking其实并算不上什么新东西,在早几年我在一些国外站点上就看见过相关的介绍,但是由于当时并没有重视这种技术,认为最多就只是用来找找未改名的mdb或者别人留下的webshell什么 ...

  10. 【分享】LateX排版软件学习教程合集

    来源于:http://www.hejizhan.com/html/xueke/416/x416_13.html  LATEX2e科技排版指南.pdf 8.3 MB  An Example LaTeX ...