python POST请求被击中两次

时间:2015-09-13 07:01:03

标签: python html wsgi

我正在做wsgi python并调用aws workspaces api来获取所有工作空间并在屏幕上呈现(网页)。但我看到我的日志,只是通过点击索引URL就可以调用该函数两次。

服务器端

ws_butt='get'
request_body_size = int(environ.get('CONTENT_LENGTH', 0))
request_body = environ['wsgi.input'].read(request_body_size)
d = parse_qs(request_body)
ws_butt=d.get('ws_butt',['get'])[0]

if ws_butt.lower()=='get':
          #calls describe_workspaces to fetch all the workspaces for the user
          new_content=[]
          for region,endpoint in region_endpoint_dict.iteritems():
              code,content=describe_workspaces(region,endpoint[0],session_username=username)
              #some processing on content and generate new_content
          if new_content:
               #some internal processing of replacing strings
               return your_workspace_window(environ, start_response,my_response=new_content)

客户端

start_response('200 OK', [('Content-Type', 'text/html')])
html_output='''
<html>
   <head>
                    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
                    <meta http-equiv="Pragma" content="no-cache" />
                    <meta http-equiv="Expires" content="0" />
                    <meta name="viewport" content="width=device-width,initial-scale=1">
                    <meta http-equiv="X-UA-Compatible" content="IE=edge">

   </head>
   <body>

    <form id="form_myws" method="POST">
    <input type="hidden" name="workspaceid" value="%s">
    <input type="hidden" name="type" value="%s">
    <input type="hidden" name="region" value="%s">
    <input type="hidden" name="state" value="%s">
    <input type="hidden" name="ipaddress" value="%s">
    <p><center><input type="submit" value="Reboot" name="ws_butt" id="submit" class="submit"/></center></p>
    </body>
    '''
    #some more processing on client side

是什么导致它致电&#34; describe_workspaces&#34;在forloop被称为&gt; =每个地区2次?检查网络元素,所有看起来都很好200OK所以我不知道是什么导致所谓的重新加载。

0 个答案:

没有答案