Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
/ stow Public archive

🔐 An example Flask app to securely PUT and GET data

License

Notifications You must be signed in to change notification settings

rossmacarthur/stow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stow

A Flask app to securely PUT and GET data.

This app was developed as a learning endeavor, in order to learn about Flask and various other packages in the Flask ecosystem.

In this example the following packages are used:

Getting started

Clone the repository

git clone git@github.com:rossmacarthur/stow.git && cd stow

Create a virtualenv using pyenv or similar, you will need to use Python 3.6 or later

pyenv virtualenv stow
pyenv local stow

Then inside the virtual environment install the app

make install-dev

Create the database and run all migrations

make migrate

Finally run the development server

make run

Stow will then be available at http://localhost:5001! 🎉

API

To store <value> under the key <key> you must PUT to /api/stow/<key> with:

{
    "value": "some interesting secret data"
}

You can then GET from /api/stow/<key> to retrieve:

{
    "value": "some interesting secret data",
    "modified": "2018-03-10T10:25:35.576296",
    "created": "2018-03-10T10:25:35.576296"
}

Of course to do the above you need to provide authorization. You must first register a user by POST to /api/user with:

{
    "name": "John Smith",
    "password": "secret1234"
}

You can then use HTTP Basic Auth with the name and password. Or if you prefer you can request a token from /api/token and use this as the HTTP Basic Auth username (in this case the password can be left blank or set to an arbitrary value). The token will last for an hour.

License

This project is licensed under the MIT License. See the LICENSE file.