Using socket programming, this task involves implementing a simple but complete web server that listens on port 5012. The server is designed to handle multiple file types, provide localized content (English/Arabic), and manage specific HTTP status codes.
The primary interface must include:
- Browser Tab: Displays "ENCS3320-T1243".
- Header: Title "Welcome to Computer Networks Webserver" at the top.
- Team Section: * Member photos (
.png), names, and IDs.- Organized in a table-like structure with separate boxes for each member.
- Brief descriptions (projects, skills, hobbies).
- Gaza Awareness Section: * Informative overview of the suffering in Gaza (war, loss, displacement, and food/water scarcity).
- Formatted with structured paragraphs, headings, bold/italic text, and
.jpgimages. - Contains both ordered and unordered lists.
- Formatted with structured paragraphs, headings, bold/italic text, and
- Event Search Form: * An input box for users to request details about specific war events.
- If the keyword matches a local file (
event_details.html), the server serves that file. - 307 Temporary Redirects: If the topic is unavailable, redirect based on input type:
- Text: Redirect to Al Jazeera Search.
- Images: Redirect to Google Images Search.
- Videos: Redirect to YouTube Search.
- If the keyword matches a local file (
- External Links: * Textbook Website
- Styling: A separate CSS file must be used to style the page attractively.
- Provide
main_ar.htmlandevent_details_ar.htmlas the Arabic counterparts to the English pages.
When an HTTP request is received, the server must:
- Log Details: Print the full HTTP request details to the terminal.
- Generate Response: Send the requested content with the correct
Content-Typeheader:text/htmlfor HTML files.text/cssfor CSS files.image/pngorimage/jpegfor images.video/mp4for videos.
The server should serve the main pages based on the following paths:
| Path / URL | Served File |
|---|---|
/, /en, /index.html, /main_en.html |
main_en.html |
/ar, /main_ar.html |
main_ar.html |
If a client requests an invalid URL, the server must return a custom error page:
- Status Line:
HTTP/1.1 404 Not Found - Browser Tab: "Error 404"
- Body Content: * "The file is not found" (displayed in red text).
- Display of the client’s IP address and port number.
NOTE: This project was done as part of the Computer Networks course in Birzeit University, T1243.
Project Info > ENCS3320