~callum/http-string-store

Flask app that provides an API for storing and retrieving strings

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~callum/http-string-store
read/write
git@git.sr.ht:~callum/http-string-store

You can also use your local clone with git send-email.

#HTTP String Store

This is a Python Flask application which provides a simple HTTP API for storing and retrieving UTF-8 strings.

#API Documentation

The Content-Type header of requests and responses must be text/plain; charset=UTF-8.

GET /new

Returns the ID of a new string store in the response body.

POST /s/<id>

Set the string with the given ID to the string in the request body. If the given ID is not already in use the server will return a 404 Not Found error. The Server may reject strings it deems too long by returning a 413 Payload Too Large error.

GET /s/<id>

Returns the string with the given ID in the response body.

#Server Setup

Requirements:

  • Python 3
  • flask
  • flask-cors (optional, CORS can be disabled by editing server.py)

Clone the repository and change to it's directory.

$ python -c "import server; server.setup_database()"
$ export FLASK_APP=server.py
$ flask run

Or you can use a different WSGI server. You may edit the constants at the start of server.py to your liking.

#Example using Curl

$ curl 'http://example.org/new'
Ig7WRA4w
$ 'http://example.org/s/Ig7WRA4w' -H "Content-Type: text/plain; charset=UTF-8" -d "Hello, World!"
success
$ curl 'http://example.org/s/Ig7WRA4w'
Hello, World!