Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haofrontend-dev/go_form_server
🎒 Go basic tutorial send form server
https://github.com/haofrontend-dev/go_form_server
form golang
Last synced: 21 days ago
JSON representation
🎒 Go basic tutorial send form server
- Host: GitHub
- URL: https://github.com/haofrontend-dev/go_form_server
- Owner: haofrontend-dev
- Created: 2024-07-04T16:29:40.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-04T16:33:19.000Z (6 months ago)
- Last Synced: 2024-07-15T08:00:36.570Z (5 months ago)
- Topics: form, golang
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Go send form basic
# Demo ServerThis is a simple server written in Go that serves static files and handles two routes: `/hello` and `/form`. The `/hello` route responds to GET requests with the message "hello". The `/form` route handles POST requests and retrieves the values of the `name` and `email` fields from the form data.
## Prerequisites
- Go installed on your machine
## Installation
1. Clone this repository to your local machine.
2. Open a terminal and navigate to the project directory.
3. Run the following command to install the required dependencies:## Usage
1. Start the server by running the following command:
2. The server will start running on port 8080. You can access it at `http://localhost:8080`.
### `/hello`
- This route responds to GET requests.
- It returns the message "hello".### `/form`
- This route handles POST requests.
- It expects form data with the following fields:
- `name`: The name of the user.
- `email`: The email address of the user.
- It returns a response with the message "POST request successful" and the values of the `name` and `email` fields.## Static Files
The server serves static files from the `./static` directory. You can add your own static files to this directory.
## Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, please submit a pull request or open an issue.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.