This project is a simple web server implemented in Rust. It is designed to handle HTTP requests and serve static files.
- Handles GET and POST requests
- Serves static files from a specified directory
- Basic routing capabilities
- Rust (latest stable version)
- Cargo (Rust package manager)
- Postgres (latest version)
You can use the rest.http file to test the HTTP endpoints of the server. Make sure you have the REST Client extension installed in your code editor.
Make sure to set up your Postgres credentials in a .env file in the root directory of the project. The .env file should contain the following variables:
DATABASE_URL=postgres://username:password@localhost/database_name
Replace username, password, and database_name with your actual Postgres credentials.
-
Clone the repository:
git clone http://github.com/yourusername/rust-web-server.git cd rust-web-server -
Build the project:
cargo build --release
-
Run database migrations:
cargo install sqlx-cli sqlx migrate run
-
Run the server:
RUST_LOG=info cargo run
-
Open your web browser and navigate to
http://localhost:8080.
You can configure the server by editing the config.toml file. Here you can set the port number, the directory for static files, and other settings.
This project is licensed under the MIT License. See the LICENSE file for details.