A simple online clipboard to easily move text between two machines connected to the internet. When you save your text you will get a unique identifier of it. To retrieve your text just use the identifier. A simple FastAPI-based application to store and retrieve short text snippets using SQLite. This project demonstrates how to use FastAPI for building a web API with basic CRUD operations and background tasks.
- Store Text: Submit text via a web form or JSON API.
- Retrieve Text: Retrieve text content by unique ID.
- Expiration Handling: Text entries expire after a configurable period, and expired entries are automatically deleted in the background.
- Concurrency: Supports simultaneous submissions and ensures unique ID generation.
- Python 3.7+
- FastAPI
- SQLite
python-dotenv
(for environment variable management)
- Clone the repository:
git clone https://github.com/vignif/pasty.git
cd pasty
- Create and activate a virtual environment:
python3 -m venv venv_ntrol
source venv_ntrol/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Set environment variables:
Create a
.env
file in the root directory and set variables as needed:
EXPIRATION_HOURS=12
DATABASE_URL=sqlite:///store.db
Run the FastAPI app locally:
uvicorn main:app --reload --port 6001
Access the web UI at http://localhost:6001.
Build and run with Docker:
docker build -t pasty .
docker run -p 6001:6001 pasty
Serverless functions are in the api/
directory. See netlify.toml
for configuration.
POST /save
— Save text, returns unique IDGET /get/{id}
— Retrieve text by IDGET /api/count
— Get current row count
Run tests with pytest:
pytest --cov=.
- Docker: See
Dockerfile
anddocker-compose.yml
for container setup. - Netlify: See
netlify.toml
for serverless deployment. - Other: Can be deployed on any platform supporting FastAPI and SQLite.
Pull requests and issues are welcome! Please add tests for new features.
See LICENSE.md
for details.