Created
December 22, 2015 22:59
-
-
Save pawl/717fb9edde7bb6748427 to your computer and use it in GitHub Desktop.
testing new s3 storage backend for flask-admin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path as op | |
from flask import Flask | |
import flask_admin as admin | |
from flask_admin.contrib.fileadmin import BaseFileAdmin | |
from flask_admin.contrib.fileadmin.s3 import S3Storage | |
# Create flask app | |
app = Flask(__name__, template_folder='templates', static_folder='files') | |
# Create dummy secrey key so we can use flash | |
app.config['SECRET_KEY'] = '123456790' | |
# Flask views | |
@app.route('/') | |
def index(): | |
return '<a href="/admin/">Click me to get to Admin!</a>' | |
# Create admin interface | |
admin = admin.Admin(app, 'Example: Files') | |
admin.add_view(BaseFileAdmin(storage=S3Storage( | |
bucket_name="testflaskadmin", | |
region="us-east-1", | |
aws_access_key_id="my_id", | |
aws_secret_access_key="my_key" | |
))) | |
# Start app | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment