0

I am trying to create a simple (to start with) app that allows for data manipulation n and then sends information to the google API to create a google sheet. I created a very simple application using examples to run docker and then to create a flask app to accept a file input. However, file uploads will not throw any errors but I can't figure out where the files are going?

With a container, where are these files going? How do I make this somewhere I can point to and access from the docker container/flask app to then do some read-ins?

I included the app and the html, the full project is here.

> import os  from flask import Flask, render_template, request, redirect, url_for
> 
> UPLOAD_FOLDER = os.getcwd() ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png',
> 'jpg', 'jpeg', 'gif'}
> 
> print("hello from python!")
> 
> app = Flask(__name__) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
> 
> @app.route('/') def index():
>     return render_template('index.html')
> 
> @app.route('/', methods=['POST']) def upload_file():
>     uploaded_file = request.files['file']
>     if uploaded_file.filename != '':
>         print("saved!")
>         uploaded_file.save(os.path.join(app.config['UPLOAD_FOLDER'], uploaded_file.filename))
>     return redirect(url_for('index'))

and the html

<!doctype html>
<html>
  <head>
    <title>File Upload</title>
  </head>
  <body>
    <h1>File Upload</h1>
    <form method="POST" action="" enctype="multipart/form-data">
      <p><input type="file" name="file"></p>
      <p><input type="submit" value="Submit"></p>
    </form>
  </body>
</html>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.