I have written a simple python flask app which takes two inputs 1) local file path of the user computer 2) folder_name and the result will be creation of a folder named "folder_name" in the mentioned file path. Its working fine when run locally at http://127.0.0.1:5000/ but when its uploaded to heroku at https://tndcrdir.herokuapp.com/ its not working. The createDir.py file is:
from flask import Flask, request, render_template
import os
app = Flask(__name__)
@app.route('/')
def my_form():
return render_template('myform.html')
@app.route('/', methods=['POST'])
def my_form_post():
thepath = request.form['path']
folder = request.form['thefolder']
os.mkdir(thepath+'\ ' + folder)
return folder
if __name__ == '__main__':
app.run(debug=True)access
And the templates/myform.html is as under:
<html>
<head>
<title>createFile</title>
</head>
<body>
<form method="POST">
<p>Enter the Path :</p><input name="path">
<p>Enter the folder name</p><input name="thefolder">
<input type="submit" value="Click to create">
</form>
</body>
</html>
Please suggest solution if there is any ?
Comments
Post a Comment