# Examples

This directory contains example applications demonstrating how to use the LevelDB Rust bindings.

## Simple Application (`simple_app`)

A basic example showing how to:
- Open a LevelDB database
- Write key-value pairs to the database
- Read data from the database

To run this example:

```bash
cd simple_app
cargo run
```

The example creates a temporary database, writes some sample data (name, version, and author), and then reads it back to display on the console.

## HTTP Server (`http_server`)

A more advanced example that exposes LevelDB operations through a RESTful HTTP API using the Actix-web framework. It provides endpoints for:
- `PUT /{key}` - Store a value for a given key
- `GET /{key}` - Retrieve the value for a given key
- `DELETE /{key}` - Delete a key-value pair

To run this example:

```bash
cd http_server
cargo run
```

The server will start on `http://127.0.0.1:8080`, and you can interact with it using curl or any HTTP client:

```bash
# Store a value
curl -X PUT -d "Hello, World!" http://127.0.0.1:8080/mykey

# Retrieve a value
curl http://127.0.0.1:8080/mykey

# Delete a key
curl -X DELETE http://127.0.0.1:8080/mykey
```

Both examples use temporary directories for the database storage, so data will be lost when the programs terminate.