コード例 #1
0
 def test_post_submit(self):
     data = {'my_input': 'my_value'}
     encoded_data = to_bytes(urlencode(data))
     response = urlopen(self.base_url + 'submit', encoded_data)
     self.assertEqual(200, response.getcode())
     self.assertEqual(response.headers['Content-type'], 'text/html')
     self.assertIn('Submitted', str(response.read()))
コード例 #2
0
 def action(environ, start_response):
     response_headers = [
         ('Location', redirect_to),
         ('Content-type', 'text/plain')
     ]
     start_response('302 Found', response_headers)
     return to_bytes('')
コード例 #3
0
 def test_post_submit(self):
     data = {"my_input": "my_value"}
     encoded_data = to_bytes(urlencode(data))
     response = urlopen(self.base_url + "submit", encoded_data)
     self.assertEqual(200, response.getcode())
     self.assertEqual(response.headers["Content-type"], "text/html")
     self.assertIn("Submitted", str(response.read()))
コード例 #4
0
ファイル: webserver.py プロジェクト: rotula/python-zombie
    def add_html(self, method, path, filename):
        filepath = os.path.join(self.base, filename)
        with open(filepath, 'r') as html_file:
            contents = to_bytes(html_file.read())

        def action(environ, start_response):
            start_response('200 OK', [('Content-Type', 'text/html')])
            return contents

        self.add_route(method, path, action)
コード例 #5
0
    def add_html(self, method, path, filename):
        filepath = os.path.join(self.base, filename)
        with open(filepath, 'r') as html_file:
            contents = to_bytes(html_file.read())

        def action(environ, start_response):
            start_response(
                '200 OK',
                [('Content-Type', 'text/html')])
            return contents

        self.add_route(method, path, action)
コード例 #6
0
ファイル: webserver.py プロジェクト: rotula/python-zombie
 def action(environ, start_response):
     response_headers = [('Location', redirect_to),
                         ('Content-type', 'text/plain')]
     start_response('302 Found', response_headers)
     return to_bytes('')
コード例 #7
0
ファイル: webserver.py プロジェクト: rotula/python-zombie
 def not_found(self):
     """Called if no URL matches."""
     self.start_response('404 NOT FOUND', [('Content-Type', 'text/plain')])
     return to_bytes('Not Found')
コード例 #8
0
 def not_found(self):
     """Called if no URL matches."""
     self.start_response(
         '404 NOT FOUND',
         [('Content-Type', 'text/plain')])
     return to_bytes('Not Found')