Seamlessly serve your static assets of your Flask app from Amazon S3

Related tags

Flaskflask-s3
Overview

flask-s3

Build Status Coverage Status Analytics PyPI Version

Seamlessly serve the static assets of your Flask app from Amazon S3.

Maintainers

Flask-S3 is maintained by @e-dard, @eriktaubeneck and @SunDwarf.

Installation

Install Flask-S3 via pypi:

pip install flask-s3

Or, install the latest development version:

pip install git+https://github.com/e-dard/flask-s3

Documentation

The latest documentation for Flask-S3 can be found here.

Comments
  • Added support for AWS CloudFront (or any other CDN)

    Added support for AWS CloudFront (or any other CDN)

    This allows you to change the base domain to anything and won't include the S3 bucket name before the url, as it does when changing S3_BUCKET_DOMAIN. I updated the docs (so you'll want to update the readthedocs.org site) and added a test for the feature.

    opened by eriktaubeneck 12
  • Refactor app.config defaults setup

    Refactor app.config defaults setup

    @e-dard Just wanted to get your thoughts on this.

    The basic idea here is that if USE_S3 is unset, then in the case where app.debug is True (and USE_S3_DEBUG is False), we'd simply turn USE_S3 to False. This offers a couple advantages:

    • No need to check app.config on every call of url_for. We simply override it if USE_S3 is True at initialization. I don't think app.config could ever change without restarting the app (and even it it's possible, it's a serious anti-pattern, I think).
    • The application can reference app.config["USE_S3"] as a definitive test as to if files are being served locally or remotely. The use case I have for this is an app that allows users to upload images, which go directly to S3 (they never exist on the web server, except in memory between the upload and the upload to S3). I use the url_for function in S3 to generate those urls still, but then locally/testing I need to upload them to the filesystem. As of now, this requires:
    if app.config['USE_S3'] and (not app.debug or app.config['USE_S3_DEBUG']):
        s3_upload()
    else: # not app.config['USE_S3'] or (app.debug and not app.config['USE_S3_DEBUG'])
        local_upload()
    

    which ideally would simplify to

    if app.config['USE_S3']:
        s3_upload()
    else: # not app.config['USE_S3']
        local_upload()
    
    opened by eriktaubeneck 9
  • Big refactoring code and tests

    Big refactoring code and tests

    • fix #16
    • prepare to be compatible with py3
    • use coverage and coveralls.io
    • using tqdm for print progress coping files (if log level = Info)
    • fix by autopep8

    All existing tests are passed.

    opened by klinkin 8
  • Naming of config variables

    Naming of config variables

    Hey folks, I just added Flask-S3 to a project, and I think the naming of the config variables ought to be changed to be specific to this module; perhaps with a FLASKS3_ prefix (like how the Flask-Security module does it).

    I already have a config var called S3_BUCKET in my project, and now I have S3_BUCKET_NAME.. Which doesn't provide the clearest distinction in the code base.

    Just a thought. Interested to see what you think.

    opened by mafrosis 6
  • socket.error when calling create_all()

    socket.error when calling create_all()

    I was trying to setup flask-s3 for my app but I kept getting a socket.error (either broken pipe or connection reset by peer) when running flask_s3.create_all(app) in a python shell as suggested in the docs. I had already made the bucket and was just trying to upload my static assets.

    The fix appears to be to set the (undocumented) config variable S3_REGION to the region in which you created your bucket. However, this caused an error for me when the create_all() function tried to call conn.create_bucket(bucket_name). By changing this call to a get_bucket() call, I was able to execute create_all() without error.

    bug 
    opened by asib 6
  • Only upload files that have been modified

    Only upload files that have been modified

    I wanted to speed up build/deploy times on our build server so this stores a list of SHA-1 hashes for all files that have been uploaded to S3. Only files with a different/unknown hash are then uploaded.

    Please note that I also changed bucket.make_public call to not be recursive as this takes a long time if you have many files, and all the files will already be set as public by Flask-S3 when they were uploaded previously. It is a bit of a compromise since if you manually added any files to S3 they won't be marked as public but I think that's a fair enough assumption.

    opened by andrewsnowden 5
  • Add the option to use path-style S3 URLs.

    Add the option to use path-style S3 URLs.

    It's sometimes desirable to use path-style URLs over virtual-host-style URLs. For example, a bucket name with a dot in it will trigger invalid SSL certificate errors on some browsers, since S3's *.s3.amazonaws.com certificate only covers single-level subdomains.

    This adds the S3_URL_STYLE setting, which can be one of 'host' or 'path', defaulting to 'host' for compatibility.

    opened by grampajoe 5
  • Add support for setting custom headers for files uploaded to S3

    Add support for setting custom headers for files uploaded to S3

    Today there's only support for setting the Cache-Control header. I've removed the S3_CACHE_CONTROL setting and added S3_HEADERS which supports setting whatever header you want:

    S3_HEADERS = {
        'Expires': 'Thu, 15 Apr 2010 20:00:00 GMT',
        'Cache-Control': 'max-age=86400',
    }
    
    opened by hannseman 5
  • Only possible to use root user

    Only possible to use root user

    I would like to make a user with restricted permissions but permission are reset to 'public-read' on each usage. This removes authorised users and restrictes writing to the account owner.

    To see this behaviour:

    • Create an IAM user with permissions to access the BUCKETNAME
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "s3:*",
                "Resource": "arn:aws:s3:::BUCKETNAME"
            }
        ]
    }
    
    • Set the bucket so that any authorised user has all permissions.
    • Run flask-s3
    • Observe to see if authorised users have no permissions on the bucket. it has reset to root write and public read.
    opened by wassname 4
  • Convert readthedocs links for their .org -> .io migration for hosted projects

    Convert readthedocs links for their .org -> .io migration for hosted projects

    As per their blog post of the 27th April ‘Securing subdomains’:

    Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.

    Test Plan: Manually visited all the links I’ve modified.

    opened by adamchainz 3
  • Latest release 0.2.13 do not defines default values for configuration keys

    Latest release 0.2.13 do not defines default values for configuration keys

    I received an update from pip for Flask-S3 from 0.2.8 to 0.2.13 but there are some strange things going on and I don't think the release should be kept there.

    For example, from the documentation is missing content on the section Flask-S3 Options, and also the code don't have default values for configuration keys (all of them, I kept receiving KeyError: 'FLASKS3_*' until I declared all of them in my config file).

    I just downgraded to 0.2.8 but I think it's best to remove this faulty release, or to fix it.

    Thanks!

    bug cantreproduce 
    opened by dappiu 3
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • docs/index.rst
    • flask_s3.py
    • test_flask_static.py

    Fixes:

    • Should read separates rather than seperates.
    • Should read relative rather than ralative.
    • Should read overridden rather than overriden.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Can't upload only a single folder in static to S3 - anyone?

    Can't upload only a single folder in static to S3 - anyone?

    Hi,

    When I upload to S3 by using flask_s3.create_all(app), I sometimes want to limit it to only the tailwind css. According to the docs, the filepath_filter_regex variable is supposed to accommodate that. In my static folder I have a gen_tailwind folder, so I would think that using flask_s3.create_all(app,filepath_filter_regex=r'^gen_tailwind') would upload only this folder. However, when I run it, nothing happens, and it doesn't give any return message.

    Anyone know what I am doing wrong?

    opened by kingkong-cmd 0
  • Github code doesn't match with uploaded Pypi version

    Github code doesn't match with uploaded Pypi version

    Current GitHub code doesn't matches with content of Pypi. For example in Pypi version (I downloaded de latest package: 0.3.3) the feature FLASKS3_ENDPOINT_URL is not implemented but in GitHub it works well:

    https://github.com/e-dard/flask-s3/blob/b8c72b40eb38a05135eec36a90f1ee0c96248f72/flask_s3.py#L409

    opened by cr0hn 0
  • Exclude some files

    Exclude some files

    When I deploy to production I'd like to exclude the sourcemap files in my static directory. I'd like a config option to exclude any "*.js.map" files so they aren't ever part of my production deploy to S3.

    Until then, I've put my sourcemaps in a different directory, outside of static, but that needs extra config for webpack and for serving them in Flask.

    opened by bridger 0
Releases(0.2.8)
Owner
Edd Robinson
Engineering at @influxdata. Work on IOx. Storage, indexing, whisky. Not in that order. 🥃 🦀
Edd Robinson
Find and notify users in your Active Directory with weak passwords

Crack-O-Matic Find and notify users in your Active Directory with weak passwords. Features: Linux-based Flask-based web app Hashcat or John cracker Au

Adrian Vollmer 92 Dec 31, 2022
Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure.

Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure. All the required libraries are already installed easily to use in any big project.

Ajay kumar sharma 5 Jun 14, 2022
A weather report application build with Python, Flask, and Geopy.

A weather report application build with Python, Flask, and Geopy. Requirements Python 3

Brandon Wallace 6 May 07, 2022
An easy way to build your flask skeleton.

Flider What is Flider Flider is a lightweight framework that saves you time by creating a MVC compliant file structure and includes basic commonly use

Trevor Engen 8 Nov 17, 2022
SeCl - A really easy to deploy and use made-on Flask API to manage your files remotely from Terminal

SeCl SeCl it's a really easy to deploy and use made-on Flask API to manage your

ZSendokame 3 Jan 15, 2022
flask-apispec MIT flask-apispec (🥉24 · ⭐ 520) - Build and document REST APIs with Flask and apispec. MIT

flask-apispec flask-apispec is a lightweight tool for building REST APIs in Flask. flask-apispec uses webargs for request parsing, marshmallow for res

Joshua Carp 617 Dec 30, 2022
A Cyberland server written in Python with Flask.

Cyberland What is Cyberland Cyberland is a textboard that offers no frontend. Most of the time, the user makes their own front end. The protocol, as f

Maxime Bouillot 9 Nov 26, 2022
Browsable web APIs for Flask.

Flask API Browsable web APIs for Flask. Status: This project is in maintenance mode. The original author (Tom Christie) has shifted his focus to API S

Flask API 1.3k Jan 05, 2023
Learn REST API with Flask, Mysql and Docker

Learn REST API with Flask, Mysql and Docker A project for you to learn to work a flask REST api with docker and the mysql database manager! Table of C

Aldo Matus 0 Jul 31, 2021
PatientDB is a flask app to store patient information.

PatientDB PatientDB on Heroku "PatientDB is a simple web app that stores patient information, able to edit the information, and able to query the data

rbb 2 Jan 31, 2022
A python package for integrating ripozo with Flask

flask-ripozo This package provides a dispatcher for ripozo so that you can integrate ripozo with Flask. As with all dispatchers it is simply for getti

Vertical Knowledge 14 Dec 03, 2018
Flask-redmail - Email sending for Flask

Flask Red Mail: Email Sending for Flask Flask extension for Red Mail What is it?

Mikael Koli 11 Sep 23, 2022
Telegram bot + Flask API ( Make Introduction pages )

Introduction-Page-Maker Setup the api Upload the flask api on your host Setup requirements Make pages file on your host and upload the css and js and

Plugin 9 Feb 11, 2022
Map Matching & Weight Completion service - Java (Springboot) & Python(Flask)

Map Matching service to match coordinates to roads using Java and Springboot. Weight Completion service to fill in missing weights in a graph, using Python and Flask.

2 May 13, 2022
Flask RESTful Web services using API to communicate between client and server.

Welcome! Open up two terminals, one for client and for server each Terminal 1 Terminal 2 Now navigate to the CW2_code directory in both like so $ cd C

Sehra Elahi 1 Nov 23, 2021
A gRpc server like Flask (像Flask一样的gRpc服务)

Mask A gRpc server just like Flask. Install Mask support pypi packages, you can simply install by: pip install mask Document Mask manual could be fou

吴东 16 Jun 14, 2022
Flask Web DRY full-stack framework by Problem Fighter

In the name of God, the Most Gracious, the Most Merciful. PF-Flask-Web Documentation Install and update using pip: pip install -U PF-Flask-Web Please

Problem Fighter 2 Jan 20, 2022
Glauth management ui created with python/flask

glauth-ui Glauth-UI is a small flask web app i created to manage the minimal glauth ldap server. I created this as i wanted to use glauth for authenti

Nils Thiele 67 Nov 29, 2022
Python web-app (Flask) to browse Tandoor recipes on the local network

RecipeBook - Tandoor Python web-app (Flask) to browse Tandoor recipes on the local network. Designed for use with E-Ink screens. For a version that wo

5 Oct 02, 2022
An flask app for fake image detector

fake_img_detector This is a ml based project: frameworks used:- Flask Google collab #Description: Here you can Upload two different looking image with

shivam kumar 7 Jun 29, 2022