Skip to content

Instantly share code, notes, and snippets.

@moali87
Last active May 22, 2017 15:11
Show Gist options
  • Save moali87/8192a5a6f9af9a4ab7e2a04016d8f7df to your computer and use it in GitHub Desktop.
Save moali87/8192a5a6f9af9a4ab7e2a04016d8f7df to your computer and use it in GitHub Desktop.
sample website and port check
#!/usr/bin/env python3
import requests
import socket
def get_page_code():
test = requests.get('http://www.google.com')
return test.status_code
def get_port(port=22):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1',port))
return result
def test_code():
assert get_page_code() == 200
def test_port():
assert get_port() == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment