Coder Social home page Coder Social logo

pastebin's Introduction

Pastebin

A simple implementation of a Pastebin-type service. If you're unfamiliar with what Pastebin is, see pastebin.com.

This is mostly done for learning and fun. It isn't production ready!

Architecture Diagram

Building

You can build everything using Docker.

To build the Pastebin image:

# Inside top level directory
docker build -t pastebin-dev -f Dockerfile .

To build the database image:

# Inside the db/ directory
docker build -t pastebin-pg -f Dockerfile .

Or, if you'd rather use docker-compose:

# Inside top level directory
docker-compose up --build

For local development, you can do:

# Ensure python 3
pyenv local 3.6.3 # or whichever version you like (3.6+ only)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Tests

Run unit tests via:

python setup.py test

API

The API is intentionally kept very simple.

GET /api/v1/pastes/<shortlink>

Get the contents of a paste from the given shortlink. If the paste doesn't exist, a 404 Not Found status code is returned. If the paste exists, it will be returned in the following JSON body:

{
  "paste_content": "hello world! this is my first paste and i'm loving it!"
}

POST /api/v1/pastes

Create a new paste. The request body must be JSON, with the following form:

{
  "paste_content": "string",
  "time_to_live": 12345, // optional, time to live of the paste in seconds
}

If a time to live isn't given the paste will never expire. Otherwise, the paste will be set to expired - and will no longer be accessible - after the specified time has passed.

Still To Do

  • Implement paste expiry using Redis queues (DONE)
  • Unit tests of async behavior
  • Integration tests of system
  • Add docstrings to API, classes, and functions

pastebin's People

Contributors

makramkd avatar reejit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.