diff --git a/app.py b/app.py index b56b7317..2904e9a8 100644 --- a/app.py +++ b/app.py @@ -1,17 +1,38 @@ from flask import Flask +from flask import render_template, request from datetime import datetime +import os app = Flask(__name__) +app.config['UPLOAD_FOLDER'] = 'tmp/' + @app.route('/') def homepage(): - the_time = datetime.now().strftime("%A, %d %b %Y %l:%M %p") - return """ -

Hello heroku

-

It is currently {time}.

+ + +
+ + +
+ + + """ + +@app.route('/uploader', methods = ['GET', 'POST']) +def upload_file(): + if request.method == 'POST': + mypath = os.getcwd()+'/tmp/' + if not os.path.isdir(mypath): + os.mkdir(mypath) + f = request.files['file'] + f.save(os.path.join(app.config['UPLOAD_FOLDER'],f.filename)) + if os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], f.filename)): + return 'file uploaded successfully' + else: + return 'file upload fail' - - """.format(time=the_time) if __name__ == '__main__': app.run(debug=True, use_reloader=True) diff --git a/runtime.txt b/runtime.txt index 78082e3a..9fbd3bf0 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.5.1 +python-3.6.8