I am making a webtool
in which I would like to upload some text files, to do so I am using flask as follows: (I have 2 scrips: 1- flask.py
and the 2nd script is: upload.html
)
flask.py
from flask import Flask, render_template, request
from werkzeug import secure_filename
app = Flask(__name__)
@app.route('/upload')
def upload_file():
return render_template('upload.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return 'file uploaded successfully'
if __name__ == '__main__':
app.run(debug = True)
and the 2nd script which is in the templates folder, is:
upload.html
<html>
<body>
<form action = "http://localhost:5000/uploader" method = "POST"
enctype = "multipart/form-data">
<input type = "file" name = "file" />
<input type = "submit"/>
</form>
</body>
</html>
when I run it, I would get this error:
AssertionError: View function mapping is overwriting an existing endpoint function: upload_file
do you know how to fix it?