anjali29singh / tiddi

⌘Tiddi⌘ is self hosted image server written in go

Home Page:https://tiddi.kunalsin9h.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My project-1

Tiddy is self hosted image server written in Go

Demo

Go to https://tiddi.kunalsin9h.dev to see a demo of the project.

Features (API)

  • Upload images
  • View images
  • Delete images
  • Update images
  • Get image details

Setup Locally

If you want to run the server inside a docker container, you can follow these instructions

Prerequisites

  • Go (latest version recommended)
  • SQLite (latest version recommended)

Steps

  1. Clone the repo
git clone https://github.com/kunalsin9h/tiddi.git
  1. Change the working directory
cd tiddi
  1. Create a database folder in the root directory
mkdir database
  1. Create a sqlite3 database file in the database folder
touch database/dev.db
  1. Crete images table in the database file
sqlite3 database/dev.db

Execute the following SQL query in the sqlite3 shell

CREATE TABLE images (
    id varchar(7) primary key,
    title varchar(255),
    image blob not null
);

Exit the sqlite3 shell

.exit
  1. Run the server
go run main.go
  1. Open http://localhost:5656 in your browser

Environment Variables

You can set the following environment variables to change the default settings of the server.

Environment Variable Default Value Description
PORT 5656 Port on which the server will run
DB ./database/dev.db Path to the database file
HOST localhost Host on which the server will run

Example

export PORT=8080
export DB=./database/prod.db
export HOST=https://tiddi.kunalsin9h.dev

go run main.go

or alternative way is set the environment while running the server

PORT=8080 DB=./database/prod.db HOST=https://tiddi.kunalsin9h.dev go run main.go

The HOST environment variable is used to generate the unique image id of the image, it is recommended to set it to the domain name of the server. HOST is also used in the sample frontend to fetch the image from the server.

API Reference

Sample Client

The Sample Frontend is available at ./src/frontend directory, it is served by the server at / route.

GET /

Upload Image

POST /upload-image/
Parameter Type Description
image []byte Required. Image bytes to upload
title string Optional. Title of the image

Response:

{
  "url": "Unique URL of the image"
}

View Image

GET /{uiid}

Image with uiid is served at this route

Get Image Details

POST /get-image/
Parameter Type Description
uiid string Required. UIID of the image

Response:

{
  "title": "Image Title",
  "image": "Base64 Encoded Image"
}

UIID is the unique image id of the image, it is generated by the server and is returned when the image is uploaded.

Delete Image

DELETE /delete-image/
Parameter Type Description
uiid string Required. UIID of the image

Update Image

PUT /update-image/
Parameter Type Description
uiid string Required. UIID of the image
image []byte Optional. Image bytes to upload
title string Optional. Title of the image

Tech Stack

Client: HTML, CSS, JavaScript

Server: Go, SQLite

Authors

License

MIT

Acknowledgements

Support

For support, email kunal@kunalsin9h.dev

Feedback

If you have any feedback, please reach out to us at kunal@kunalsin9h.dev

Contributing

Contributions are always welcome!

Enjoy! 🚀

About

⌘Tiddi⌘ is self hosted image server written in go

https://tiddi.kunalsin9h.dev/

License:MIT License


Languages

Language:Go 76.0%Language:HTML 22.4%Language:Dockerfile 1.6%