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
This repo contains the Flask API to expose model and get predictions.

Tea Leaf Quality Srilanka Chapter This repo contains the Flask API to expose model and get predictions. Expose Model As An API Model Trainig will happ

DuKe786 2 Nov 12, 2021
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
Rich implementation for Flask

Flask Rich Implements the Rich programming library with Flask. All features are toggleable, including: Better logging Colorful tracebacks Usage Import

BD103 13 Jun 06, 2022
Getting Started with Docker and Flask

Getting-Started-with-Docker-and-Flask Introduction Docker makes it easier, simpler and safer to build, deploy and manage applications in a docker cont

Phylis Jepchumba 1 Oct 08, 2021
This is a Flask web app which predicts fare of Flight ticket

Flight Fare Prediction: Table of Content Demo Overview Motivation Installation Deployement on Heroku Directory Tree Bug / Feature Request Future scope

Ayshwarya 1 Jan 24, 2022
Flask-template - A simple template for make an flask api

flask-template By GaGoU :3 a simple template for make an flask api notes: you ca

GaGoU 2 Feb 17, 2022
A simple way to demo Flask apps from your machine.

flask-ngrok A simple way to demo Flask apps from your machine. Makes your Flask apps running on localhost available over the internet via the excellen

117 Dec 27, 2022
Simple flask api. Countdown to next train for each station in the subway system.

Simple flask api. Countdown to next train for each station in the subway system.

Kalyani Subbiah 0 Apr 17, 2022
Full text search for flask.

flask-msearch Installation To install flask-msearch: pip install flask-msearch # when MSEARCH_BACKEND = "whoosh" pip install whoosh blinker # when MSE

honmaple 197 Dec 29, 2022
A Python chat app built with Flask that runs in the browser.

A Python chat app built with Flask that runs in the browser. Designed for local area networks that are not connected to the Internet.

Leonard Kleber 1 Dec 23, 2021
Flask Multiple Database Login

Flask Multiple Database Login Handle login with flask using two diferent databases: UE | European; BR | Brazilian; These databases are separed to resp

Jose Pedro 1 Dec 16, 2021
Flask 文档中文翻译

Flask 中文文档 这里是 Flask 文档中文翻译项目,欢迎参与! 在开始翻译之前,请务必阅读下面的 Contributing Guide 了解贡献流程,然后阅读这个 Issue 了解翻译要求,在这个 Discussion 投票选出你认为合适的翻译词汇,在这个 Discussion 投票选出你喜

Grey Li 93 Nov 28, 2022
A template themes for phyton flask website

Flask Phyton Web template A template themes for phyton flask website

Mesin Kasir 2 Nov 29, 2021
Flask Application Structure with MongoDB

This application aims to serve as a template for APIs that intend to use mongoengine and flask-restx

Tiago Franco 5 Jun 25, 2022
Criando um Bot com PYAUTOGUI e utilizando o Flask para Interface para Usuário

Criando um Bot com PYAUTOGUI e utilizando o Flask para Interface para Usuário O pyautogui foi escolhido pela possibilidade de fazer a identificação do

Rodrigo Vital 2 Oct 20, 2021
Python Flask API service, backed by DynamoDB, running on AWS Lambda using the traditional Serverless Framework.

Serverless Framework Python Flask API service backed by DynamoDB on AWS Python Flask API service, backed by DynamoDB, running on AWS Lambda using the

Andreu Jové 0 Apr 17, 2022
Flask-Discord-Bot-Dashboard - A simple discord Bot dashboard created in Flask Python

Flask-Discord-Bot-Dashboard A simple discord Bot dashboard created in Flask Pyth

Ethan 8 Dec 22, 2022
Are-You-OK is a Flask-based, responsive Web App to monitor whether the Internet Service you care about is still working.

Are-You-OK Are-You-OK is a Flask-based, responsive Web App to monitor whether the Internet Service you care about is still working. Demo-Preview Get S

Tim Qiu 1 Oct 28, 2021
A flask extension using pyexcel to read, manipulate and write data in different excel formats: csv, ods, xls, xlsx and xlsm.

Flask-Excel - Let you focus on data, instead of file formats Support the project If your company has embedded pyexcel and its components into a revenu

247 Dec 27, 2022
Small flask based opds catalog designed to serve a directory via OPDS

teenyopds Small flask based opds catalog designed to serve a directory via OPDS, it has currently only been verified to work with KyBook 3 on iOS but

Adam Furbee 4 Jul 14, 2022