Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from flask import Flask, request
  2. from werkzeug.utils import secure_filename
  3. import os
  4. app = Flask(__name__)
  5.  
  6. @app.route('/')
  7. def hello_world():
  8.     return 'Hello, World!'
  9.  
  10. FOLDER = 'Recordings/'
  11. if not os.path.exists(FOLDER):
  12.     os.makedirs(FOLDER)
  13. @app.route('/file' , methods=['GET' , 'POST'])
  14. def upload_file():
  15.     try:
  16.         if request.method == 'POST':
  17.             f = request.files['DBFile']
  18.             f.save(FOLDER+secure_filename(f.filename))
  19.             return 'File uploaded successfully'
  20.     except Exception as e:
  21.         print("Exception while running upload_file()" + str(e))
  22.         raise (e)
  23. if __name__ == '__main__':
  24.     app.run(host="0.0.0.0", port=5000, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement