A simple Rust web application with an HTTP server that provides both a web UI and REST API endpoints.
- Web UI showing "Hello World" with a modern interface
- REST API endpoints:
- GET
/api/hello
: Returns a "Hello, world!" message - GET
/api/hello/:name
: Returns a personalized greeting with the provided name
- GET
- Rust (latest stable version)
- Cargo (included with Rust)
- Clone this repository
- Navigate to the project directory
- Run the application:
cargo run
The server will start on http://127.0.0.1:3000
src/main.rs
: Main application code with server implementationstatic/
: Directory for static web files (created automatically on first run)Cargo.toml
: Project configuration and dependencies
Returns a JSON response with a "Hello, world!" message.
Example response:
{
"message": "Hello, world!"
}
Returns a JSON response with a personalized greeting.
Example request: /api/hello/John
Example response:
{
"message": "Hello, John!"
}
The web UI is available at the root URL (http://127.0.0.1:3000) and provides a simple interface to test the API endpoints.