forked from PriyankaKhire/ProgrammingPracticePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.py
More file actions
31 lines (25 loc) · 721 Bytes
/
Client.py
File metadata and controls
31 lines (25 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#Tiny URL Client
import socket
import sys
sys.path.append("..")
from ColorText import ColorText
import random
class Client(object):
def __init__(self):
self.id = random.randint(1, 300)
self.longURL = None
self.s = socket.socket()
def displayPage(self):
ct = ColorText()
ct.display(4*"\t"+"Tiny URL", "red-highlight")
def run(self):
#self.displayPage()
self.longURL = raw_input("Enter a long URL to make tiny:\n")
#To connect to port of server
port = 7
self.s.connect(('127.0.0.1', port))
self.s.send(self.longURL)
self.s.close()
#Main
obj = Client()
obj.run()