Skip to content

dollardeploy/example-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Web Server Example

A simple web server built with Rust and Actix-web that serves an HTML page on localhost with configurable port.

Features

  • 🚀 Built with Rust and Actix-web framework
  • 🌐 Serves a beautiful HTML page with modern styling
  • ⚙️ Configurable port via environment variable
  • 📊 JSON API endpoint for status information
  • 📁 Static file serving capability
  • 🔧 Standard Rust build process

Prerequisites

  • Rust (latest stable version)
  • Cargo (comes with Rust)

Quick Start

1. Build the project

cargo build

2. Run the server

Default port (8080):

cargo run

Custom port:

PORT=3000 cargo run

3. Access the application

Development

Build for release

cargo build --release

Run release version

./target/release/example-rust-web

Run with custom port

PORT=9000 ./target/release/example-rust-web

Build for a specific target architecture

To cross-compile for a different architecture, first install the target with rustup, then build with cargo build --target:

For amd64 (x86_64):

cargo build --release --target x86_64-unknown-linux-gnu

For arm64 (aarch64):

cargo build --release --target aarch64-unknown-linux-gnu

The resulting binary will be in target/<target-triple>/release/.

Project Structure

example-rust/
├── Cargo.toml          # Project dependencies and metadata
├── src/
│   └── main.rs         # Main application code
├── static/             # Static files directory (optional)
└── README.md           # This file

API Endpoints

  • GET / - Serves the main HTML page
  • GET /api/status - Returns JSON status information
  • GET /static/* - Serves static files from the static directory

Environment Variables

  • PORT - Server port (default: 8080)

Dependencies

  • actix-web - Web framework
  • actix-files - Static file serving
  • serde - Serialization/deserialization
  • tokio - Async runtime
  • chrono - Date and time utilities
  • env_logger - Logging

License

This is an example project for educational purposes.

About

Boilerplate for simple Rust webapp

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages