Created
April 10, 2012 15:58
-
-
Save rduplain/2352388 to your computer and use it in GitHub Desktop.
Flask: serving static file from a separate domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://flask.pocoo.org/mailinglist/archive/2012/4/10/serving-static-file-from-a-separate-domain-in-production/ | |
| from flask import Flask, url_for | |
| # Uncomment to set server name. | |
| # SERVER_NAME = 'mianos.com' | |
| app = Flask(__name__, static_folder=None) | |
| app.config.from_object(__name__) | |
| app.add_url_rule('/<path:filename>', endpoint='static', | |
| view_func=app.send_static_file, subdomain='static') | |
| @app.route('/') | |
| def index(): | |
| return url_for('static', filename='style.css') | |
| if __name__ == '__main__': | |
| app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I use "app.debug = True" and "app.run(host='0.0.0.0', port=5000)", the static content will be given the port 5000 while testing. Is there any way around this?