Giter Site home page Giter Site logo

snippets's Introduction

Snippets

A simple key-value store application with human-readable keys using Google App Engine.

Setup

Install Google App Engine SDK for Python.

Create a new project in the console.

Clone the repository and deploy to your new project.

appcfg.py update . --application your_project_id

Usage

This application is intended to be a straight-forward way to store arbitrary data as part of another program.

Storing data

We can store data by making an HTTP POST request which returns a human-readable key in plaintext.

$ curl -X -POST --data "arbitrary data" https://your_project_id.appspot.com
24-graceful-crocodiles-meandered-sadly

Retrieving data

We can retrieve data by making an HTTP GET request which returns our data in plaintext.

$ curl https://your_project_id.appspot.com/24-graceful-crocodiles-meandered-sadly
arbitrary data

Extras

We can specify a key using the path of the request. The request will fail if the key is already in use.

$ curl -X -POST --data "more arbitrary data" https://your_project_id.appspot.com/some-specific-key
some-specific-key

You can get a list of all the stored keys delineated by newline. This is useful for manually looking at the data coming in, but not much else.

$ curl https://your_project_id.appspot.com/list
24-graceful-crocodiles-meandered-sadly
some-specific-key

In app.yaml there are some parameters you can set.

env_variables:
    EXPIRE_SNIPPETS: False
    EXPIRATION_TIME_IN_DAYS: 31
    MAX_BYTES_PER_SNIPPET: 1048576
    ALLOW_UUID_OVERRIDE: True
    READS_PER_MINUTE: 60
    WRITES_PER_MINUTE: 10
    LISTS_PER_MINUTE: 10
  • You can set the maximum size of the data. The default is 1MB.
  • You can enable expiration and set the expiration time. A cron will run every 24 hours and delete key-value pairs that exceed the expiration time.
  • You can configure rate limiting by IP address. This alone won't be enough to stop someone determined. Instead use Google App Engine's built in DoS protection.
  • You can disable the ability to specify a key. If you disable this, all requests with a specified key will fail.

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.