Bottle GET method. Request
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,跟这个比较相似。一样的道理。 < > 标签。
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的更多相关文章
- sencha touch Ext.Ajax.request 错误 Cannot call method 'request' of undefined 解决方案
凡是Cannot call method '' of undefined 这类错误大部分都可以参照下面的办法来解决 在st中有时候你会发现使用Ext.Ajax.request会出现一下错误: Cann ...
- 使用bottle进行web开发(2):http request
我们知道,http request有多个方法,比如get,post,delete,patch,put等.对用的,bottle都定义了相应的装饰器,目前定义了五个: get(),post(),put() ...
- Python自动化运维之29、Bottle框架
Bottle 官网:http://bottlepy.org/docs/dev/index.html Bottle是一个快速.简洁.轻量级的基于WSIG的微型Web框架,此框架只由一个 .py 文件,除 ...
- Bottle 中文文档
译者: smallfish (smallfish.xy@gmail.com) 更新日期: 2009-09-25 原文地址: http://bottle.paws.de/page/docs (已失效) ...
- Recipes — Bottle 0.13-dev documentation
Recipes - Bottle 0.13-dev documentation Recipes¶ This is a collection of code snippets and examples ...
- 用Bottle开发web程序(一)
Bottle Bottle是一个轻量级的web app框架.相较与django等框架,bottle几乎没有任何依赖,而且只有一个文件.而相对于python默认的SimpleHTTPServer,功能更 ...
- bottle源码
import sys __author__ = 'Marcel Hellkamp' __version__ = '0.13-dev' __license__ = 'MIT' ############# ...
- bottle框架剖析
bottle框架剖析 使用 源码分析 一.使用 大致有以下几部分 quick start request routing generate contents request Data template ...
- python之Bottle框架
一.简单的Bottle框架 1)bottle框架简介 安装 pip install bottle Bottle是一个快速.简洁.轻量级的基于WSIG的微型Web框架. 此框架只由一个 .py 文件,除 ...
随机推荐
- 多线程编程 (2) -NSOperation
一.NSInvocationOperation 二.NSBlockOperation 三.NSOperation的其他用法 四.自定义NSOperation 1.上一讲简单介绍了NSThread的使用 ...
- Linux httpd 跳转简单方法二
使用mod_proxy 这种方法要添加上mod_proxy_http.so 在httpd.conf 中打开httpd-vhost 在 httpd-vhost 里面添加上 <VirtualHost ...
- DELL iDRAC 远程虚拟机报错:虚拟介质分离或所选虚拟磁盘驱动器的虚拟介质重定向已由另一用户使用
原因很简单,那就是虚拟介质的映射功能,只能被使用一次. 推荐做法: 1.由于通过远程,在Lifecycle Controller里DeployOS安装系统,需要在虚拟介质里映射ISO,因此映射功能要留 ...
- Javascript实战开发:教你使用raphael.js绘制中国地图
最近的数据统计项目中要用到中国地图,也就是在地图上动态的显示某个时间段某个省份地区的统计数据,我们不需要flash,仅仅依靠raphael.js以及SVG图像就可以完成地图的交互操作.在本文中,我给大 ...
- ubuntu下的词典的安装
因为从事开发,安装一个词典是很有必要,文中介绍安装openyoudao和stardic两个软件的方法 一.openyoudao的安装 因为是由window转来学ubuntu的,所以总是想安装和wind ...
- C语言JSON-RPC
近期对json-rpc比較感兴趣,思想非常easy,并且看到了非常多不同语言的实现.在github上 hmngomes 的 json-rpc-c (实现的是server端,基于TCP流),短 ...
- ThoughtWorks Merchant's Guide To The Galaxy
ThoughtWorks笔试题之Merchant's Guide To The Galaxy解析 一.背景 在某网站上看到ThoughtWorks在武汉招人,待遇在本地还算不错,就投递了简历.第二天H ...
- 为ASP.NET MVC应用程序创建更复杂的数据模型
为ASP.NET MVC应用程序创建更复杂的数据模型 2014-05-07 18:27 by Bce, 282 阅读, 1 评论, 收藏, 编辑 这是微软官方教程Getting Started wit ...
- WCF基于MSMQ的事件代理服务
前言 公司目前楼主负责的项目正在改版升级,对之前的服务也在作调整,项目里有个操作日志的模块,就决定把日志单独提取出来,做个日志服务,所以就有了这篇文章 正文 MSMQ作为消息队列,B/S项目调用日志服 ...
- SQLSERVER一些公用DLL
SQLSERVER一些公用DLL的作用解释 SQLSERVER一些公用DLL的作用解释 如果你的SQLSERVER安装在C盘的话,下面的路径就是相应SQLSERVER版本的公用DLL的存放路径 S ...