金字塔和要求

时间:2014-06-19 01:14:09

标签: python-2.7 pyramid python-requests

这是我的服务器:

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

def post(request):
    print request
    return Response('temp')

if __name__ == '__main__':
    config = Configurator()
    config.add_route('measure','/measure')
    config.add_view(post,route_name='measure',request_method='POST')
    app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 8080, app)
    server.serve_forever()

和客户:

import json
import requests
import time

url = 'http://'localhost':8080/measure'
temp = 10
headers = {'content-type': 'application/json'}

while True:
r = requests.post(url, data=json.dumps(temp), headers=headers)
time.sleep(4)

我的问题是:如何在我的浏览器上看到发送的数据,我搜索但找不到任何内容,我的意思是response(temp),它只是给出了一个错误,如“全球临时不存在”或类似的东西。

0 个答案:

没有答案