Experiment 2 Networking HTTP API (2)
Experiment 2 Networking HTTP API (2)
Objective
Prerequisites
- Python 3.x installed
- Flask framework (`pip install flask`)
- Web browser or cURL for testing
mkdir http_server_experiment
cd http_server_experiment
host = 'localhost'
port = 8000
python http1.py
app = Flask(__name__)
@app.route('/get')
def get_method():
return jsonify(message="GET Request Success"), 200
@app.route('/post', methods=['POST'])
def post_method():
return jsonify(message="POST Request Success"), 201
@app.route('/notfound')
def not_found():
return jsonify(error="Resource Not Found"), 404
if __name__ == '__main__':
app.run(debug=True)
python app.py
4. Test the Flask endpoints using these exact commands:
Required Screenshots
1. For Basic HTTP Server (Experiment 1):
- Screenshot 1: Terminal showing server running
- Screenshot 2: Browser or curl output showing directory listing
- Name these files as: `exp1_server.png` and `exp1_output.png`
Screenshot Requirements
1. Each screenshot must:
- Show the full terminal window or browser window
- Include timestamp (system clock) visible in the screenshot
- Be clearly readable with good resolution
- Show the command being executed and its output
Submission Format
1. Create a ZIP file named `HTTP_Server_Experiment_<YourName>` containing:
- All four screenshots named as specified above
- Source code files (`http1.py` and `app.py`)
- A brief text file named `readme.txt` containing:
- Your name and date of experiment
- Python version used
- Flask version used
- Any issues encountered and their resolution
Validation Checklist
Before submitting, verify that:
- Both servers run without errors
- All endpoints return expected responses
- Screenshots show complete output
- Source code files are included
- readme.txt is complete
- All files are named correctly
Note: Partial or incorrectly formatted submissions will not be accepted. Ensure all outputs match
exactly with the expected outputs shown above.
3. Connection refused:
- Error: "Connection refused"
- Solution: Verify the server is running and port number is correct
Remember: If you encounter any issues not listed here, document them and their solutions in
your readme.txt file.