{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# DevOps Lesson\n", "\n", "- toc: true\n", "- categories: []\n", "- type: pbl" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "216.239.38.120\n" ] } ], "source": [ "import socket\n", "\n", "# Change the following host and see what IP it prints!\n", "host = \"google.com\"\n", "ip = socket.gethostbyname(host)\n", "\n", "print(ip)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Successfully connected!\n" ] } ], "source": [ "# Initiate a TCP connection to port 80\n", "with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:\n", " s.connect((ip, 80))\n", " print(\"Successfully connected!\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Check-In\n", "\n", "1. What is an IP address?\n", "2. What is a TCP port?" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "HTTP/1.1 200 OK\n", "Date: Wed, 26 Apr 2023 20:42:23 GMT\n", "Expires: -1\n", "Cache-Control: private, max-age=0\n", "Content-Type: text/html; charset=ISO-8859-1\n", "Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-P8iyfLS7sVOMtw4VH_ETZg' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp\n", "P3P: CP=\"This is not a P3P policy! See g.co/p3phelp for more info.\"\n", "Server: gws\n", "X-XSS-Protection: 0\n", "X-Frame-Options: SAMEORIGIN\n", "Set-Cookie: 1P_JAR=2023-04-26-20; expires=Fri, 26-May-2023 20:42:23 GMT; path=/; domain=.google.com; Secure\n", "Set-Cookie: AEC=AUEFqZfIZR7D7_Ir2nIxXQkdrgQ18Zio2oRGrMvTMIr4PGb2PJ9hu1PLcLU; expires=Mon, 23-Oct-2023 20:42:23 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax\n", "Set-Cookie: NID=511=RgU6-HAk4FzeCRp2vMqoKEru0hdLT770SuNXFL1iziw3mwOoF5arW3cFVuo7GHAWGuo7PkElFUcTu8IFBA2aq29bSyM-XSX9fTotRtfAvGZSItButC2QxxcCTnJiTeAzoFrXUfatqlXqPZpFSMAv1vCuoFIRuIv5-ddMM8c9vfE; expires=Thu, 26-Oct-2023 20:42:23 GMT; path=/; domain=.google.com; HttpOnly\n", "Accept-Ranges: none\n", "Vary: Accept-Encoding\n", "Transfer-Encoding: chunked\n", "\n", "5c4e\n", "