tornado同步和异步GET
来源:互联网 发布:cc2541中文数据手册 编辑:程序博客网 时间:2024/04/30 22:58
import hashlib
import tornado
import tornado.httpclient
import tornado.gen
token = '654321'
appsecret = 'B450744A16159A1F8B8201B394F2EA42'
appkey = '3B815C7FC3A568CCB26AA2937C915EF0'
password = hashlib.sha1((token + appsecret).encode()).hexdigest()
url = "http://192.168.1.201:7000/v1/app_data/data1000000030563792"
# 异步获取
@tornado.gen.coroutine
def AsyncTest():
print("This is post")
print(response.body)
# 同步获取
def test():
http_client = tornado.httpclient.HTTPClient()
response = http_client.fetch(url, method='GET', auth_username=appkey, auth_password=password)
print(response.body)
import tornado
import tornado.httpclient
import tornado.gen
token = '654321'
appsecret = 'B450744A16159A1F8B8201B394F2EA42'
appkey = '3B815C7FC3A568CCB26AA2937C915EF0'
password = hashlib.sha1((token + appsecret).encode()).hexdigest()
url = "http://192.168.1.201:7000/v1/app_data/data1000000030563792"
# 异步获取
@tornado.gen.coroutine
def AsyncTest():
print("This is post")
http = tornado.httpclient.AsyncHTTPClient()
# auth_username和auth_password发送到对发为headers中的以下内容
# Authorization: Basic base64_auth_string; base64_auth_string = base64(appkey:sha1(token+appsecret))
response = yield tornado.gen.Task(http.fetch, url, method='GET', auth_username=appkey, auth_password=password)print(response.body)
# 同步获取
def test():
http_client = tornado.httpclient.HTTPClient()
response = http_client.fetch(url, method='GET', auth_username=appkey, auth_password=password)
print(response.body)
0 0
- tornado同步和异步GET
- get请求 同步 和异步
- UIday1604:get同步/异步 和 post同步/异步 编程实现
- gevent和tornado异步
- get post 同步 异步
- Get请求和Post请求 同步下载和异步下载
- iOS 同步和异步 Get和Post请求
- 6.15 网络请求,Get和Post,同步和异步
- 网络编程-GET-同步和异步(delegate和block)
- XHR 实例 GET 和 POST 异步和同步
- SNMP 使用SNMP4J V2进行同步和异步 GET,SET
- SNMP 使用SNMP4J V2进行同步和异步 GET,SET
- iOS开发 -- GET 和 POST请求(同步异步链接)
- SNMP4j实现同步和异步的GET的示例
- Swift3.0:Get/Post同步和异步请求
- okHttpClient异步同步的get和post请求方法
- OKHttp异步get,post请求和同步请求
- 网络请求 同步get 同步post 异步get 异步post
- 各种品牌/组装电脑一键u盘启动快捷键表
- 集合的理解
- Convolutional neural networks(CNN) (九) Implement deep networks for digit classification Exercise
- 时长清理电脑垃圾
- JAVA学习笔记--final、finally、finalize的区别
- tornado同步和异步GET
- 平衡二叉树理解
- jQuery 对动态生成元素进行事件绑定
- Ubuntu安装pip easy_install virtualenv mysql命令
- HDOJ 1116 Play on Words(欧拉回路)
- 985的0-1串难题
- 继承、封装、多态
- poj-2485-Hightway【最小生成树】
- HDU 5787 K-wolf Number 数位dp