A simple asynchronous Rust web server that counts words from books stored in Redis.
Built using:
- Exposes a JSON API to retrieve the top words from a specified book.
- Asynchronous Redis connection for fast data access.
- Designed for easy extension (e.g., supporting
.epubuploads).
Returns the top N most frequent words for a book.
curl http://localhost:3000/api/top-words[
{"word": "the", "count": 42},
{"word": "and", "count": 37},
{"word": "pride", "count": 20},
{"word": "prejudice", "count": 18},
{"word": "elizabeth", "count": 15}
]Lists all available book titles currently stored in Redis.
curl "http://localhost:3000/api/books"[
"pride-and-prejudice",
"moby-dick",
"war-and-peace"
]Uploads a new book (plain text .txt only for now).
title(text): Title of the book.file(file): Plain text file containing the book content.
curl -F "title=my-new-book" -F "file=@/path/to/book.txt" http://localhost:3000/api/uploadBook uploaded successfully
or
Failed to save book
- Clone the repository:
git clone https://github.com/your-username/my-wordcount-server.git
cd wordcount-server-rust
- Set up your environment:
cp .env.example .env
# Edit .env to match your Redis server details
- Run the server:
cargo run
- Access the API at:
a. http://localhost:3000/api/top-words
- Allow dynamic book selection via query parameters.
- Accept
.epubuploads to extract and process book text automatically. - Improve outputs (Include extra visualizations).
- Update UI/UX to be more enjoyable/visually appealing.
This project is licensed under the MIT License.