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:
- Flask.
- Flask-Bcrypt provides bcrypt hashing utilities.
- Flask-Classful adds class based views.
- Flask-HTTPAuth provides Basic, Digest and Token HTTP authentication.
- Flask-Login provides user session management.
- Flask-Migrate provides migration support using Alembic.
- Flask-SQLAlchemy adds support for SQLAlchemy.
- Flask-WTF provides integration with WTForms.
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! 🎉
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.
This project is licensed under the MIT License. See the LICENSE file.