May 29th, 2020
Q: Which island if I can ask?
A1: Probably worth asking at the end of lecture, I don’t want to interrupt this story :)
Q: do you need Dog.py saved to your pycharm in order to use the Dog function?
A1: yes, it should be in the same folder as the program making the dog.
Q: do you need bark(self) or just ()?
A1: live answered
Q: Is there a way to create a lot of instances of a class with different names (i.e. from Wednesday's lecture, ball1, ball2... ball50) at once (maybe within a loop) without writing ball1 = Ball() 50 times?
A1: Nope - if you want to refer to it by name, you need to make it explicitly. One way to get around this is by putting them in a list or a dict and refer to by index or key.
A2: You could have a list of balls.
Q: are both the messages sent and received by the client strings?
A1: Yes!
Q: Wait, is Facebook primarily written in Python?
A1: Lots of it is, but it’s not *just* Python! The idea is that it could be made with Python, though
Q: Where is SimpleServer.run_server coming from?
A1: There’s a SimpleServer library that’s imported at the top of the file
Q: What is SimpleInternet?
A1: A library that’s imported into this program
Q: SimpleServer.run_server <- do we always use this? is this generalizable beyond this example?
A1: Any example in 106A will use this - other tools have different ways of setting up a server
Q: why do you call it response? why cant you just ask to request something to the server
A1: You request something from the server, and it sends you back a response - those are different things - it’s like requests are parameters and the response is a return value
Q: is the internet address the IP address?
A1: Yep!
Q: can you use any server port? what made chris choose 8000 ?
A1: It’s the ‘default’ one for servers, but you can choose basically any port (some are reserved for other things) and there’s a maximum number but I don’t know what it is :)
Q: Do we need to run it in pycharm as we go, or can we just refresh in the borwser?
A1: Any time the server is changed, you’ll need to restart it
Q: if i search localhost:8000 on my computer right now will it show this site?
A1: Nope - it’s just on Chris’ computer (that’s what localhost means)
A2: No. You'd need to run a server on your own computer (at port 8000) for that to work.
Q: Do the variables under __init__ apply only when you create the instance? I notice that the hits aren’t going back to 0 (which we don’t want anyway), so is it passing over that initial variable?
A1: The first time the request is made, we increase the count before we print, so we didn’t see the 0
Q: So to send the command via the link, we put a “/“ first, and if we want to send the parameter, we put a “?” first?
A1: Yep!
Q: so does the client send a message made up of a dictionary with two keys, and the server prints a list with two strings?
A1: It sends a request, which contains a string command and a dictionary of parameters
Q: What does it mean when people say the server “crashed”?
A1: It just means that the program the server was running had an error and stopped working. This is often the result of a bad message.
A2: Mehran answered this in the chat: in short, that the server program crashed
Q: how do you send an image over the server if it has to be a string? Are you just sending over the rgb values?
A1: There’s actually a way of converting images to strings by representing their RGB values!
Q: What was the bug??
A1: live answered
A2: What was the bug??
Q: when will assignment 7 be released?
A1: Monday
Q: What was msg = params[‘msg’] (or something like that)? What does that do?
A1: live answered
Q: so json dumps converts strings to dictionaries?
A1: live answered
A2: other way around! variables to strings