Skip to content

haileyesus2433/thumbnail-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Thumbnail Server

A thumbnail server built using the Axum Rust framework with SQLite as a database. This application allows users to upload images, tag them, search by tags, and automatically generate thumbnails.

## Features

- Image upload with custom tags
- Automatic thumbnail generation (100x100px)
- Search images by tags
- List all uploaded images
- View individual images and thumbnails
- Automatic regeneration of missing thumbnails on startup

## Prerequisites

- Rust and Cargo
- SQLite

## Setup

### Clone the repository:

```sh
git clone https://github.com/haileyesus2433/thumbnail-server.git
cd thumbnail-server
```

### Configure the database:

Create a `.env` file with your database configuration:

```sh
echo "DATABASE_URL=sqlite:thumbnail.db" > .env
```

### Create an images directory:

```sh
mkdir -p images
```

### Build and run the application:

```sh
cargo run
```

The server will start on [http://127.0.0.1:8000](http://127.0.0.1:8000).

## API Endpoints

- `GET /` - Main page with upload form
- `POST /upload` - Upload an image with tags
- `POST /search` - Search images by tags
- `GET /image/{id}` - Get the original image by ID
- `GET /thumbnail/{id}` - Get the thumbnail of an image by ID
- `GET /images` - List all images with their tags
- `GET /test` - Check the number of images in the database

## Usage

### Uploading Images

Visit the main page at [http://127.0.0.1:8000](http://127.0.0.1:8000) and use the form to upload an image with tags.

### Searching Images

Use the search form to find images by tags. The search is case-sensitive and supports partial matches.

### Viewing Images

- Original images can be accessed at `/image/{id}`
- Thumbnails can be accessed at `/thumbnail/{id}`

## Technical Details

- **Framework**: Axum for HTTP server
- **Database**: SQLite with SQLx for database operations
- **Image Processing**: Uses the `image` crate for thumbnail generation
- **Concurrency**: Leverages Tokio for asynchronous operations
- **File Storage**: Images are stored on the filesystem with database references

## Project Structure

```
thumbnail-server/
├── src/
│   ├── main.rs          # Main application code
│   ├── index.html       # Upload form template
│   ├── search.html      # Search results template
│   ├── redirect.html    # Redirect page after upload
├── migrations/          # SQLx database migrations
├── images/              # Directory for storing uploaded images and thumbnails
├── .env                 # Environment variables
├── Cargo.toml           # Rust dependencies and project metadata
```

## License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published