Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @app.route('/', methods=['GET'])
  2. def index():
  3. # Main page
  4. return render_template('index.html')
  5.  
  6.  
  7. @app.route('/predict', methods=['GET', 'POST'])
  8. def upload():
  9. if request.method == 'GET':
  10. return render_template('index.html')
  11.  
  12. if request.method == 'POST':
  13. # Get the file from post request
  14. f = request.files['file']
  15. # Save the file to ./uploads
  16. basepath = os.path.dirname(__file__)
  17. file_path = os.path.join(
  18. basepath, 'static', secure_filename(f.filename))
  19. f.save(file_path)
  20.  
  21. result = model_predict(file_path, model)
  22.  
  23. return jsonify(result)
  24.  
  25. return None
  26.  
  27.  
  28.  
  29. if __name__ == '__main__':
  30. # app.run(port=5002, debug=True)
  31.  
  32. # Serve the app with gevent
  33. http_server = WSGIServer(('', 5000), app)
  34. http_server.serve_forever()
  35. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement