Skip to content

Instantly share code, notes, and snippets.

@ezirmusitua
Last active January 17, 2019 15:26
Show Gist options
  • Save ezirmusitua/d1f85bff8b13bca74a7b5f8231ad9794 to your computer and use it in GitHub Desktop.
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
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