def get_server_info(url, method, headers): info = {} res = request(url, "HEAD", headers=headers) server = res["headers"].get("server", "Unknown") info["software"] = server if headers: info["headers"] = dict(headers) return info
def print_server_info(url, method, headers=None, stream=sys.stdout): stream.write("-------- Server info --------\n\n") res = request(url, "HEAD", headers=headers) server = res["headers"].get("server", "Unknown") stream.write(f"Server Software: {server}\n") if headers: for k, v in headers.items(): stream.write(f"{k}: {v}\n") stream.write("\n") stream.flush()
def something_sync(args): grab = request("http://localhost:8888") self.assertEqual(grab["status"], 200) grab_json = json_request("http://localhost:8888/molotov.json") self.assertTrue("molotov" in grab_json["content"])
def something_sync(args): grab = request('http://localhost:8888') self.assertEqual(grab['status'], 200) grab_json = json_request('http://localhost:8888/molotov.json') self.assertTrue('molotov' in grab_json['content'])
async def _setup_session(wid, session): with coserver(): html = str(request("http://localhost:8888")) content.append(html)