- 浏览: 362013 次
- 性别:
- 来自: 四川
文章分类
- 全部博客 (247)
- 数据库以及sql (11)
- java (48)
- 爬虫学习 (20)
- java编程 (28)
- python编程以及安装和配置 (27)
- oracle数据库 (32)
- mongodb基本操作 (4)
- linux学习 (7)
- easyUI (2)
- nodeJs (8)
- python学习 (16)
- 其他 (13)
- hadoop (1)
- svn (1)
- 汉字 (1)
- windows (2)
- jsp (5)
- fiddler (1)
- ETL (1)
- teamviewer (1)
- maven (4)
- GIT (2)
- datagrip (1)
- ocr (1)
- redis (3)
- mysql (3)
- linux (1)
- 数据服务 (0)
最新评论
=======================get请求
# coding=utf-8
'''
Created on 2017年5月9日
@author: chenkai
'''
import bottle
def check_login(username, password):
if username == 'kaige' and password == '123456':
return True
else:
return False
@bottle.route('/login')
def login():
if bottle.request.GET.get('do_submit','').strip(): #点击登录按钮
# 第一种方式(latin1编码)
## username = bottle.request.GET.get('username','').strip() # 用户名
## password = bottle.request.GET.get('password','').strip() # 密码
#第二种方式(获取username\password)(latin1编码)
getValue = bottle.request.query_string
## username = bottle.request.query['username'] # An utf8 string provisionally decoded as ISO-8859-1 by the server
## password = bottle.request.query['password'] # 注:ISO-8859-1(即aka latin1编码)
#第三种方式(获取UTF-8编码)
username = bottle.request.query.username # The same string correctly re-encoded as utf8 by bottle
password = bottle.request.query.password # The same string correctly re-encoded as utf8 by bottle
if check_login(username, password):
return "<p>登录成功</p>"
else:
return "<p>登陆失败,用户名或者密码错误</p>"
else:
return ''' <form action="/login" method="get">
Username: <input name="username" type="text" />
Password: <input name="password" type="password" />
<input value="Login" name="do_submit" type="submit">
</form>
'''
bottle.run(host='localhost', port=8083)
运行这个py程序后,浏览器输入:http://localhost:8083/login , 输入用户名和密码,点击登录
===================================post请求
# coding=utf-8
'''
Created on 2017年5月9日
@author: chenkai
'''
import bottle
def check_login(username, password):
if username == 'kaige' and password == '123456':
return True
else:
return False
@bottle.route('/login')
def login():
return ''' <form action="/login" method="post">
Username: <input name="username" type="text" />
Password: <input name="password" type="password" />
<input value="Login" type="submit">
</form>
'''
@bottle.route('/login', method='POST')
def do_login():
# 第一种方式
# username = request.forms.get('username')
# password = request.forms.get('password')
#第二种方式
postValue = bottle.request.POST.decode('utf-8')
username = bottle.request.POST.get('username')
password = bottle.request.POST.get('password')
if check_login(username, password):
return "<p> 登录成功</p>"
else:
return "<p> 登录失败 </p>"
bottle.run(host='localhost', port=8083)
运行这个py程序后,浏览器输入:http://localhost:8083/login , 输入用户名和密码,点击登录,这个明显是post请求, 而且浏览器不会显示参数
# coding=utf-8
'''
Created on 2017年5月9日
@author: chenkai
'''
import bottle
def check_login(username, password):
if username == 'kaige' and password == '123456':
return True
else:
return False
@bottle.route('/login')
def login():
if bottle.request.GET.get('do_submit','').strip(): #点击登录按钮
# 第一种方式(latin1编码)
## username = bottle.request.GET.get('username','').strip() # 用户名
## password = bottle.request.GET.get('password','').strip() # 密码
#第二种方式(获取username\password)(latin1编码)
getValue = bottle.request.query_string
## username = bottle.request.query['username'] # An utf8 string provisionally decoded as ISO-8859-1 by the server
## password = bottle.request.query['password'] # 注:ISO-8859-1(即aka latin1编码)
#第三种方式(获取UTF-8编码)
username = bottle.request.query.username # The same string correctly re-encoded as utf8 by bottle
password = bottle.request.query.password # The same string correctly re-encoded as utf8 by bottle
if check_login(username, password):
return "<p>登录成功</p>"
else:
return "<p>登陆失败,用户名或者密码错误</p>"
else:
return ''' <form action="/login" method="get">
Username: <input name="username" type="text" />
Password: <input name="password" type="password" />
<input value="Login" name="do_submit" type="submit">
</form>
'''
bottle.run(host='localhost', port=8083)
运行这个py程序后,浏览器输入:http://localhost:8083/login , 输入用户名和密码,点击登录
===================================post请求
# coding=utf-8
'''
Created on 2017年5月9日
@author: chenkai
'''
import bottle
def check_login(username, password):
if username == 'kaige' and password == '123456':
return True
else:
return False
@bottle.route('/login')
def login():
return ''' <form action="/login" method="post">
Username: <input name="username" type="text" />
Password: <input name="password" type="password" />
<input value="Login" type="submit">
</form>
'''
@bottle.route('/login', method='POST')
def do_login():
# 第一种方式
# username = request.forms.get('username')
# password = request.forms.get('password')
#第二种方式
postValue = bottle.request.POST.decode('utf-8')
username = bottle.request.POST.get('username')
password = bottle.request.POST.get('password')
if check_login(username, password):
return "<p> 登录成功</p>"
else:
return "<p> 登录失败 </p>"
bottle.run(host='localhost', port=8083)
运行这个py程序后,浏览器输入:http://localhost:8083/login , 输入用户名和密码,点击登录,这个明显是post请求, 而且浏览器不会显示参数
发表评论
-
Pycharm常用快捷键
2018-10-17 16:45 711pycharm常用快捷键 1、编辑(Editing) Ctr ... -
python连接oracle数据库报错PI-1047: 64-bit Oracle Client library cannot be loaded: "解决方案
2018-10-17 16:44 7133错误原因:instantclient版本为32位,需更换成64 ... -
pycharm安装第三方库的方式
2018-10-16 17:33 19821.点击settings之后再点击project下面的proj ... -
pycharm中配置中文头, 不用每次都写
2018-10-16 17:20 1777打开file->settings->Editor- ... -
python 中__name__ = '__main__' 的作用
2018-09-14 09:50 1592出自:https://www.cnblogs.com/alan ... -
python中的textblob库的作用说明
2018-09-14 09:40 3756TextBlob 是一款 Pythonic 的文本处理工具,用 ... -
python 利用bottle微服务提供post接口,供第三方调用
2018-09-12 16:11 1160=============================== ... -
python中的请求参数乱码 解决
2018-09-12 15:39 1262import urllib def geturltoutf8 ... -
python 安装nltk
2018-09-07 18:02 33411、在cmd窗口中,进入到python的文件夹内的 Scrip ... -
python 情感分析
2018-09-07 17:05 1644转:https://blog.csdn.net/u011001 ... -
python结巴分词
2018-03-20 14:46 571# coding=utf-8 ''' Created on 2 ... -
anaconda安装与配置环境变量,以及anaconda是什么,有什么用。
2017-07-12 10:15 10654anaconda安装与配置环境变量: 官网:https://w ... -
python中利用adb shell 控制手机,完美解决中文输入问题
2017-06-03 10:25 53271.连接手机, 打开开发者选项, 连接USB, (如果需要记录 ... -
selenium设置网页文本框中文值报错解决方法
2017-03-20 10:06 1012selenium设置网页文本框中文值报错解决方法 elem = ... -
python多进程和多线程的区别
2017-03-14 17:33 1111多线程和多进程最大的 ...
相关推荐
python做get和post请求
主要介绍了关于python的bottle框架跨域请求报错问题的处理方法,需要的朋友可以参考下
用Python和TCP sockets手写了一个可以接收HEAD、GET和POST等request message的简单的 HTTP web服务器。
1.安装对应的库 2.将test_http_copy.py代码复制到自己的服务器或电脑上 3.python test_http_copy.py启动或(ohup python -u test_http_copy.py > test.log 2>&1 & 后台启动) 4.使用postman调用自测。
本文研究的主要是Python使用requests发送POST请求的相关内容,具体介绍如下。 一个http请求包括三个部分,为别为请求行,请求报头,消息主体,类似以下这样: 请求行 请求报头 消息主体 HTTP协议规定post提交的...
主要介绍了Python的Bottle框架中实现最基本的get和post的方法的教程,Bottle框架在Python开发者中的人气很高,需要的朋友可以参考下
采用python3编写的用于处理服务器端POST处理和客户端的get的数据请求
主要介绍了Python大数据之网络爬虫的post请求、get请求区别,结合具体实例形式分析了Python网页爬虫post请求与get请求相关使用技巧,需要的朋友可以参考下
python web的bottle框架文档。Bottle是一个简单高效的遵循WSGI的微型python+Web框架。说微型,是因为它只有一个文件,除Python标准库外,它不依赖于任何第三方模块。&oq=Bottle是一个简单高效的遵循WSGI的微型python...
Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例Python入门经典实例...
使用python的bottle框架开发的一个留言本的实例,此实例在apache的wsgi模式下工作良好,第一次学习,有很多疏漏希望大家多多指教http://www.richdata.org/archives-209-richdata.html
python3接口测试框架带实例,适合新手学习入门,读取Excel用例,生成测试报告
python项目框架实例代码,python框架,项目框架,基础框架,python web框架代码 , python网站框架代码
当前Python Web开发中的框架算Django最为流行了,但是本文介绍的是一个较为轻量级的Web框架:Bottle框架。理论性的东西就不讲了,直接上实例代码。 1.问题描述 最近做一个系统的后台开发,用的就是Python+Bottle...
python--playwright修改GET/POST请求参数,抓包修改数据,内含: 1、index.py主代码,演示完整的抓包修改数据demo 2、flaskServer.py服务端,用于返回传入的参数 运行顺序: 先运行:python flaskServer.py 然后再...
Python基于Django框架实现的一个学生信息管理系统源码 Python基于Django框架实现的一个学生信息管理系统源码 Python基于Django框架实现的一个学生信息管理系统源码 Python基于...
本资源为本人实际项目在使用的通信框架,长连接,多线程,包含通信消息结构实例,封包、解包以及粘包、拆包的处理等,代码注释清晰简单,python3,无其他依赖,质量可靠