Last active
January 17, 2019 15:26
-
-
Save ezirmusitua/d1f85bff8b13bca74a7b5f8231ad9794 to your computer and use it in GitHub Desktop.
[csv2xlsx flask app demo] demo code for blog post https://ezirmusitua.site/posts/deep-in-flask-upload-and-download/ #blog #demo #python
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
def create_app(test_config=None): | |
# create and configure the csv2xlsx | |
app = Flask(__name__, instance_relative_config=True) | |
app.config.from_mapping(SECRET_KEY='dev') | |
if test_config is None: | |
# load the instance config, if it exists, when not testing | |
app.config.from_pyfile('config.py', silent=True) | |
else: | |
# load the test config if passed in | |
app.config.from_mapping(test_config) | |
# ensure the instance folder exists | |
try: | |
os.makedirs(app.instance_path) | |
except OSError: | |
pass | |
app.add_url_rule('/', 'index', views.index) | |
app.add_url_rule('/', 'download', views.handle_and_download, methods=('POST',)) | |
app.add_url_rule('/ping', 'ping', views.hello) | |
return app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment