{"id":25818752,"url":"https://github.com/cybersayak/webserver1stapp","last_synced_at":"2025-02-28T08:13:29.089Z","repository":{"id":249796817,"uuid":"832546990","full_name":"Cybersayak/WebServer1stApp","owner":"Cybersayak","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-04T18:22:57.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-07T03:01:52.134Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"replit.com/@SAYAKGHOSH10/WebServer1stApp","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cybersayak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-23T08:40:48.000Z","updated_at":"2024-09-04T18:23:00.000Z","dependencies_parsed_at":"2024-07-23T12:19:15.070Z","dependency_job_id":"91aaa18d-64cc-47f9-a457-65cb2fff1115","html_url":"https://github.com/Cybersayak/WebServer1stApp","commit_stats":null,"previous_names":["cybersayak/webserver1stapp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cybersayak%2FWebServer1stApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cybersayak%2FWebServer1stApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cybersayak%2FWebServer1stApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cybersayak%2FWebServer1stApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cybersayak","download_url":"https://codeload.github.com/Cybersayak/WebServer1stApp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241122116,"owners_count":19913409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-28T08:13:28.562Z","updated_at":"2025-02-28T08:13:29.081Z","avatar_url":"https://github.com/Cybersayak.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basic Web Server in Golang\n\nThis repository contains a simple web server implementation using Go (Golang). The server responds with a html pages message for every request.\n\n## Prerequisites\n\nBefore you begin, ensure you have met the following requirements:\n- You have installed [Go](https://golang.org/doc/install) (at least version 1.16).\n- You have a working internet connection.\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone (https://github.com/Cybersayak/WebServer1stApp.git)\n\nSure! Here's a README for your Web Server project that renders HTML pages:\n\n---\n\n## Project Structure\n\n```\n.\n├── main.go\n└── static\n    ├── form.html\n    └── index.html\n```\n\n## Files\n\n### `main.go`\n\nThis is the entry point of the application. It sets up the HTTP server and routes.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc formHandler(w http.ResponseWriter, r *http.Request) {\n\tif err := r.ParseForm(); err != nil {\n\t\tfmt.Fprintf(w, \"ParseForm() err: %v\", err)\n\t}\n\tfmt.Fprint(w, \"POST request successful\")\n\tname := r.FormValue(\"name\")\n\taddress := r.FormValue(\"address\")\n\temail := r.FormValue(\"email\")\n\tfmt.Fprintf(w, \"Name = %s\\n\", name)\n\tfmt.Fprintf(w, \"Address = %s\\n\", address)\n\tfmt.Fprintf(w, \"Email = %s\\n\", email)\n}\n\nfunc helloHandler(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/hello\" {\n\t\thttp.Error(w, \"404 not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, \"Method not allowed\", http.StatusNotFound)\n\t\treturn\n\t}\n\tfmt.Fprint(w, \"Hello Commanders\")\n}\n\nfunc main() {\n\tfileServer := http.FileServer(http.Dir(\"./static\"))\n\thttp.Handle(\"/\", fileServer)\n\thttp.HandleFunc(\"/form\", formHandler)\n\thttp.HandleFunc(\"/hello\", helloHandler)\n\tfmt.Printf(\"Starting server on port 8080\\n\")\n\tif err := http.ListenAndServe(\":8080\", nil); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n\n### `static/form.html`\n\nThis is the HTML template for the home page.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eStatic Site in Golang\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003c/form\u003e\n    \u003cform action=\"/form\" method=\"post\"\u003e\n      \u003clabel for=\"name\"\u003eName:\u003c/label\u003e\u003cbr\u003e\n      \u003cinput type=\"text\" id=\"name\" name=\"name\"\u003e\u003cbr\u003e\n      \u003clabel for=\"address\"\u003eAddress:\u003c/label\u003e\u003cbr\u003e\n      \u003cinput type=\"text\" id=\"address\" name=\"address\"\u003e\u003cbr\u003e\n      \u003clabel for=\"emailaddress\"\u003eEmail:\u003c/label\u003e\u003cbr\u003e\n      \u003cinput type=\"email\" id=\"email\" name=\"email\"\u003e\u003cbr\u003e\u003cbr\u003e\n        \n      \u003cinput type=\"submit\" value=\"Submit\"\u003e\n    \u003c/form\u003e \n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### `static/index.html`\n\nThis is the HTML template for the about page.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n    \u003ctitle\u003eAbout Page\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eWelcome to the About Page\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Running the Project\n\n1. Ensure you have Go installed on your machine.\n2. Clone the repository or copy the project structure to your local machine.\n3. Navigate to the project directory.\n4. Run the application using the following command:\n\n```sh\ngo run main.go\n```\n\n5. Open your web browser and navigate to `http://localhost:8000` to see the home page.\n6. Navigate to `http://localhost:8000/about` to see the about page.\n\n## Conclusion\n\nThis project provides a simple example of how to set up a basic web server in Go with handlers, template rendering, and HTML templates. You can expand this project by adding more routes, templates, and functionality as needed.\n\n\n---\n\nYou can find the project repository [here](https://github.com/Cybersayak/WebServer1stApp).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybersayak%2Fwebserver1stapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcybersayak%2Fwebserver1stapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcybersayak%2Fwebserver1stapp/lists"}