How to enable CORS in flask

Here is what worked for me when I deployed to Heroku. http://flask-cors.readthedocs.org/en/latest/ Install flask-cors by running – pip install -U flask-cors from flask import Flask from flask_cors import CORS, cross_origin app = Flask(__name__) cors = CORS(app) app.config[‘CORS_HEADERS’] = ‘Content-Type’ @app.route(“https://stackoverflow.com/”) @cross_origin() def helloWorld(): return “Hello, cross-origin-world!”

setting an environment variable in virtualenv

In case you’re using virtualenvwrapper (I highly recommend doing so), you can define different hooks (preactivate, postactivate, predeactivate, postdeactivate) using the scripts with the same names in $VIRTUAL_ENV/bin/. You need the postactivate hook. $ workon myvenv $ cat $VIRTUAL_ENV/bin/postactivate #!/bin/bash # This hook is run after this virtualenv is activated. export DJANGO_DEBUG=True export S3_KEY=mykey export … Read more

Make Heroku run non-master Git branch

You can push an alternative branch to Heroku using Git. git push heroku-dev test:master This pushes your local test branch to the remote’s master branch (on Heroku). Comment from @Brian Armstrong: Worth noting also, when you’re ready to go back to master you need to do git push -f heroku master:master

Rails: How to reference images in CSS within Rails 4

Sprockets together with Sass has some nifty helpers you can use to get the job done. Sprockets will only process these helpers if your stylesheet file extensions are either .css.scss or .css.sass. Image specific helper: background-image: image-url(“logo.png”) Agnostic helper: background-image: asset-url(“logo.png”, image) background-image: asset-url($asset, $asset-type) Or if you want to embed the image data in … Read more

How to restart a rails server on Heroku?

The answer was: heroku restart -a app_name # The -a is the same as –app Easily aliased with alias hra=”heroku restart –app ” Which you can make a permanent alias by adding it to your .bashrc or .bash_aliases file as described at: https://askubuntu.com/questions/17536/how-do-i-create-a-permanent-bash-alias and Creating permanent executable aliases Then you can just type hra app_name … Read more

Heroku and GitHub: “Items could not be retrieved, Internal server error”

As of May 25, 2022, at 19:52 UTC, GitHub integration has been re-enabled: We are happy to report that the GitHub integration is re-enabled! You can now reconnect with GitHub and restore your Heroku pipeline functionality, including Review Apps, with newly generated tokens. You can connect to GitHub immediately or wait for the enhanced integration … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)