heroku-python / flask-heroku Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Heroku environment variable configurations for Flask.
Home Page: http://pypi.python.org/pypi/flask-heroku/
[DEPRECATED] Heroku environment variable configurations for Flask.
Home Page: http://pypi.python.org/pypi/flask-heroku/
This package is out of date on PyPI. The version retrieved with pip install flask-heroku does not have the init_app() method.
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.
Flask-Redis appears to utilize this setting. It should work with both RedisCloud and RedisToGo as both seem semi-supported.
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?
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.
Shouldn't it import from flask.ext.heroku
instead of flask_heroku
? And what about init_app
?
This explains the issue. I had the same problem as the user. Seems they were using flask-heroku, and the environment variable does not get picked up by alembic.
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.
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
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?
Please upload the current version to PyPI, so we can all benefit from MONGOLAB_URI
:)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.