GithubHelp home page GithubHelp logo

heroku-python / flask-heroku Goto Github PK

View Code? Open in Web Editor NEW
227.0 10.0 34.0 20 KB

[DEPRECATED] Heroku environment variable configurations for Flask.

Home Page: http://pypi.python.org/pypi/flask-heroku/

Python 100.00%

flask-heroku's Introduction

Flask-Heroku

This is a simple Flask extension that sets configuration defaults for Heroku-esque environment variables.

This is far from conclusive. Send a pull request to add a new service!

Usage

Usage is pretty simple:

from flask import Flask
from flask.ext.heroku import Heroku

app = Flask(__name__)
heroku = Heroku(app)

Configuration is already set up:

>>> app.config['SQLALCHEMY_DATABASE_URI']
postgres://...

Alternatively, Flask's application factory pattern is supported:

heroku = Heroku()
# Then, later...
heroku.init_app(app)

Install

Installation is simple:

$ pip install flask-heroku

flask-heroku's People

Contributors

awsum avatar cburmeister avatar dcrosta avatar ferrix avatar gmacon avatar kennethreitz avatar lyndsysimon avatar mattstibbs avatar singingwolfboy avatar tedmiston avatar tonyseek avatar vmax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-heroku's Issues

MongoDB URI with multiple nodes (host:port separated by a comma) raises `invalid literal for int()` error

A MongoDB URI can specify multiple, comma separated host:port URL parts like this:

mongodb://username:password@host1:123,host2:456/database

A URL in this form will result in an error:

ValueError: invalid literal for int() with base 10

I have a solution which uses pymongo.uri_parser.parse_uri (if installed) to parse the the MongoDB URL, selecting the first node (or, host:port) to extract the port, hostname and database.

Update PyPI

Please upload the current version to PyPI, so we can all benefit from MONGOLAB_URI :)

PyPI out of date

This package is out of date on PyPI. The version retrieved with pip install flask-heroku does not have the init_app() method.

debug=1 if not on Heroku?

I'm not sure if this is out of the scope of this project, but it would be awesome if it detected if it was running on Heroku and added app.debug=1 if not.

Setting fallback values for local development

What would be the proper way to set fallback values in case DATABASE_URL (for example) is not set on a development environment?

Right now the proper way seems to be:

from os import environ
heroku = Heroku(app)
if 'DATABASE_URL' not in environ:
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'

Is there any way to get this fallback behavior from flask-heroku?

Do not set BROKER_TRANSPORT

I'm not entirely sure the purpose of this setting, but it seems in (at least) Celery 3.1 it should not be configured, or it should be configured with something else (I think just 'redis'). I've never ever had to configure this myself, so it's probably better to just remove this configuration.

Setting it to None before Flask-Heroku inits resolves the issue, as it prevents it from setting it.

Mailgun + Flask-Mail

I just assumed (incorrectly) that by setting up the Heroku Mailgun extension, and seeing that it was listed in this project, that everything would just work.

But then I realized I still needed to do:

app.config['MAIL_SERVER'] = app.config['SMTP_SERVER']
app.config['MAIL_USERNAME'] = app.config['SMTP_LOGIN']
app.config['MAIL_PASSWORD'] = app.config['SMTP_PASSWORD']

http://packages.python.org/Flask-Mail/

perhaps you should add that?

Easier start when using together with Flask-PyMongo

The Flask app configuration values for MongoDB are different between flask-heroku and Flask-PyMongo, so I have to remap them, like this:

app = Flask(__name__)
heroku = Heroku(app)
app.config.update(
    MONGO_USERNAME=app.config['MONGODB_USER'],
    MONGO_PASSWORD=app.config['MONGODB_PASSWORD'],
    MONGO_HOST=app.config['MONGODB_HOST'],
    MONGO_PORT=app.config['MONGODB_PORT'],
    MONGO_DBNAME=app.config['MONGODB_DB'],
)
mongo = PyMongo(app)

Is there anything that can be done to make this easier, ideally to require just the following?

app = Flask(__name__)
heroku = Heroku(app)
mongo = PyMongo(app)

Thanks

Support REDIS_URL

Flask-Redis appears to utilize this setting. It should work with both RedisCloud and RedisToGo as both seem semi-supported.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.