Skip to content

FOSS-Community/paste.py

Repository files navigation

paste.py 🐍


paste.py 🐍 - A pastebin written in python.

πŸ€” Pre-requisites

  • python3
  • pdm

🐍 Python Version Support

This project is designed to be compatible with specific versions of Python for optimal performance and stability.

Supported Python Version

  • Python 3.11.3

❗️ For the best experience and performance, it is recommended to use the version mentioned above.

Before diving into the project, ensure that you have the correct Python version installed. To check the version of Python you currently have, execute the following command in your terminal:

python --version

🐍 Installing Python 3.11.3 with pyenv

Protip: Managing multiple Python versions is a breeze with pyenv. It allows you to seamlessly switch between different Python versions without the need to reinstall them.

If you haven't installed pyenv yet, follow their official guide to set it up.

Once you have pyenv ready, install the recommended Python version by running:

pyenv install 3.11.3

When you navigate to this project's directory in the future, pyenv will automatically select the recommended Python version, thanks to the .python-version file in the project root.

πŸ“¦ Setup

Local setup πŸ› οΈ with Docker 🐳

  • Installing and running: Before you begin, ensure you have docker installed. If not, refer to the official documentation to install docker.

    docker pull mrsunglasses/pastepy
    docker run -d -p 8080:8080 --name pastepyprod mrsunglasses/pastepy
  • Using docker-compose: You can also use docker-compose to run the project locally by running the following command:

    • Clone the repository: Get the project source code from GitHub:
    git clone https://github.com/FOSS-Community/paste.py.git
    • Navigate to the Project Directory:
    cd paste.py
    • Run the project using docker-compose:
    docker-compose up

Local setup πŸ› οΈ without Docker 🐳

Setting Up the Project with PDM

PDM (Python Development Master) is utilized for dependency management in this project. To set up and run the project:

  • Installing PDM: Before you begin, ensure you have PDM installed. If not, refer to the official documentation to install PDM.

  • Clone the Repository: Get the project source code from GitHub:

    git clone https://github.com/FOSS-Community/paste.py.git
  • Navigate to the Project Directory:

    cd paste.py
  • Install Dependencies: Use PDM to install the project's dependencies:

    pdm install
  • Start the Project: Use PDM to run the project:
    pdm run start
    • You can also use pdm run dev to start the dev server.

Setting Up and Testing the Project

To ensure the code quality and functionality of the project, follow the steps below:

Installing Git Hooks with pre-commit

Before making any commits, it's essential to ensure that your code meets the quality standards. This project utilizes pre-commit hooks to automatically check your changes before any commit.

Install the pre-commit hooks with the following command:

pre-commit install

Running Tests

To ensure the project's functionality, you should run all the provided tests. Execute the following command to run the tests:

pdm run test

Testing the Running Server

Once you have your server up and running, you can send requests to it from another terminal to test its responsiveness and functionality.

Here are a couple of GET requests you can make using curl:

curl http://0.0.0.0:8080/health

These endpoints typically return the health status or readiness of the server, helping in diagnostics and monitoring.

πŸ—’οΈ How to contribute

❗️Important: Please read the Code of Conduct and go through Contributing Guideline before contributing to paste.py

  • Feel free to open an issue for any clarifications or suggestions.

Uasge:

Uisng CLI

cURL is required to use the CLI.

  • Paste a file named 'file.txt'
curl -X POST -F "file=@file.txt" https://paste.fosscu.org/file
  • Paste from stdin
echo "Hello, world." | curl -X POST -F "file=@-" https://paste.fosscu.org/file
  • Delete an existing paste
curl -X DELETE https://paste.fosscu.org/paste/<id>

Using the web interface:

Go here


For info API usage and shell functions, see the website.