Question
. Select one of the following topics, implement it in your code, and explain its basics in your report: 1. TSL/SSL (security): should secure all
. Select one of the following topics, implement it in your code, and explain its basics in your report:
1. TSL/SSL (security): should secure all your packet transactions. Use Wireshark to examine the exchanged packets. You must show that it is working in the online presentation and include pieces of evidence in your report (screenshots of the packet data).
2. Object-Oriented Programming: use object-oriented programming in your coding. Describe, in your report, the basics of OO in Python, and your classes.
3. GUI: use a graphical user interface for the client. It should be easy to use and clear to read. The user should send all requests using the GUI.
(Server Script)
import json
import requests
import threading
import socketserver
# Constants
GROUP_ID = 12345 # replace with your group ID
API_KEY = "your_api_key" # replace with your API key
API_URL = "http://api.aviationstack.com/v1/flights"
# Get user input for airport code
arr_icao = input("Enter airport code: ")
# Retrieve data from API
params = {
"access_key": API_KEY,
"arr_icao": arr_icao,
"limit": 100
}
response = requests.get(API_URL, params=params)
# Extract data from response
data = response.json()
# Save data to JSON file
filename = f"{GROUP_ID}.json"
with open(filename, "w") as f:
json.dump(data, f)
# Set up server
class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
def handle(self):
# Get client's name
self.name = self.request.recv(1024).decode().strip()
print(f"Accepted connection from {self.name}")
# Wait for requests from client
while True:
request = self.request.recv(1024).decode().strip()
# Check request type
if request == "arrived flights":
# Search data for arrived flights and send matching information
pass
elif request == "delayed flights":
# Search data for delayed flights and send matching information
pass
elif request.startswith("flights from"):
# Search data for flights from a specific city and send matching information
pass
elif request.startswith("details of flight"):
# Search data for details of a particular flight and send matching information
pass
elif request == "quit":
# Close connection and leave
break
print(f"Closed connection from {self.name}")
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
pass
# Start server
server = ThreadedTCPServer(("localhost", 10000), ThreadedTCPRequestHandler)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.daemon = True
server_thread.start()
print("Server is running")
# Wait for user input to stop server
input("Press Enter to stop server")
# Stop server
server.shutdown()
server.server_close()
(Client Script)
import socket
# Constants
SERVER_HOST = "localhost"
SERVER_PORT = 10000
# Set up client
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((SERVER_HOST, SERVER_PORT))
# Get user input for username
username = input("Enter username: ")
# Send username to server
client.send(username.encode())
# Display menu and wait for user input
while True:
print("""
Menu:
1. Arrived flights
2. Delayed flights
3. All flights from a specific city
4. Details of a particular flight
5. Quit
""")
choice = input("Enter your choice: ")
if choice == "1":
# Send request for arrived flights to server
pass
elif choice == "2":
# Send request for delayed flights to server
pass
elif choice == "3":
# Send request for flights from a specific city to server
pass
elif choice == "4":
# Send request for details of a particular flight to server
pass
elif choice == "5":
# Send request to quit and close connection
pass
# Close connection
client.close()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started