Skip to content

Commit 6b6b03c

Browse files
authored
Add files via upload
1 parent 3c91c04 commit 6b6b03c

File tree

3 files changed

+179
-0
lines changed

3 files changed

+179
-0
lines changed

CGI_programming.ipynb

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"#! C:\\User\\Utkarsh\\AppData\\Local\\conda\\conda\\pkgs\\python.exe\n",
10+
"\n",
11+
"print('Content-type:text/html\\r\\n\\r\\n')\n",
12+
"print('<html>')\n",
13+
"print('<head>')\n",
14+
"print('<title>Hello World</title>')\n",
15+
"print('</head>')\n",
16+
"print('<body>')\n",
17+
"print('<h2>Hello this is Utkarsh</h2>')\n",
18+
"print('</body>')\n",
19+
"print('</html>')"
20+
]
21+
}
22+
],
23+
"metadata": {
24+
"kernelspec": {
25+
"display_name": "Python 3",
26+
"language": "python",
27+
"name": "python3"
28+
},
29+
"language_info": {
30+
"codemirror_mode": {
31+
"name": "ipython",
32+
"version": 3
33+
},
34+
"file_extension": ".py",
35+
"mimetype": "text/x-python",
36+
"name": "python",
37+
"nbconvert_exporter": "python",
38+
"pygments_lexer": "ipython3",
39+
"version": "3.7.0"
40+
}
41+
},
42+
"nbformat": 4,
43+
"nbformat_minor": 2
44+
}

Email_sending.ipynb

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import smtplib"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"content='This is an email from Utkarsh'\n",
19+
"body='\\r\\n'.join(['To: %s'%'recievers id',content])\n",
20+
"#smtp object created\n",
21+
"mail=smtplib.SMTP('smtp.gmail.com',587)\n",
22+
"mail.starttls()\n",
23+
"mail.login('username','password')\n",
24+
"try:\n",
25+
" mail.sendmail('sender','recievers id',' content')\n",
26+
" #send your message\n",
27+
" print('Mail sent')\n",
28+
"except:\n",
29+
" print('Error Occured')\n",
30+
" \n",
31+
"#closing email id\n",
32+
"mail.close()\n",
33+
" "
34+
]
35+
}
36+
],
37+
"metadata": {
38+
"kernelspec": {
39+
"display_name": "Python 3",
40+
"language": "python",
41+
"name": "python3"
42+
},
43+
"language_info": {
44+
"codemirror_mode": {
45+
"name": "ipython",
46+
"version": 3
47+
},
48+
"file_extension": ".py",
49+
"mimetype": "text/x-python",
50+
"name": "python",
51+
"nbconvert_exporter": "python",
52+
"pygments_lexer": "ipython3",
53+
"version": "3.7.0"
54+
}
55+
},
56+
"nbformat": 4,
57+
"nbformat_minor": 2
58+
}

client_and_server_program.ipynb

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import socket as sr"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"#server program\n",
19+
"s= sr.socket() #creating a socket\n",
20+
"print('Socket Created..')\n",
21+
"port= 12345 #setting a port number\n",
22+
"host= sr.gethostname()\n",
23+
"s.bind((host,port)) #binding to specific ip and port\n",
24+
"print('Socket binded to port')\n",
25+
"\n",
26+
"s.listen(5) #put socket to listening \n",
27+
"print('Socket is listening')\n",
28+
"\n",
29+
"while True:\n",
30+
" #establish a connection to client\n",
31+
" c,addr=s.accept()\n",
32+
" print('Got connection from',addr)\n",
33+
" \n",
34+
" c.send(b'Thank you for conecting ...............') #sending a message to client\n",
35+
" \n",
36+
" c.close() #close connection with client\n",
37+
" \n",
38+
" "
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": null,
44+
"metadata": {},
45+
"outputs": [],
46+
"source": [
47+
"#client program\n",
48+
"cl=sr.socket() #creating a socket\n",
49+
"port=12345 #setting a port number \n",
50+
"cl.connect(('127.0.0.1',port)) #connecting to server\n",
51+
"print(cl.recv(1024)) # recieving to server\n",
52+
"cl.close()"
53+
]
54+
}
55+
],
56+
"metadata": {
57+
"kernelspec": {
58+
"display_name": "Python 3",
59+
"language": "python",
60+
"name": "python3"
61+
},
62+
"language_info": {
63+
"codemirror_mode": {
64+
"name": "ipython",
65+
"version": 3
66+
},
67+
"file_extension": ".py",
68+
"mimetype": "text/x-python",
69+
"name": "python",
70+
"nbconvert_exporter": "python",
71+
"pygments_lexer": "ipython3",
72+
"version": "3.7.0"
73+
}
74+
},
75+
"nbformat": 4,
76+
"nbformat_minor": 2
77+
}

0 commit comments

Comments
 (0)