Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/', methods=['GET'])
- def index():
- # Main page
- return render_template('index.html')
- @app.route('/predict', methods=['GET', 'POST'])
- def upload():
- if request.method == 'GET':
- return render_template('index.html')
- if request.method == 'POST':
- # Get the file from post request
- f = request.files['file']
- # Save the file to ./uploads
- basepath = os.path.dirname(__file__)
- file_path = os.path.join(
- basepath, 'static', secure_filename(f.filename))
- f.save(file_path)
- result = model_predict(file_path, model)
- return jsonify(result)
- return None
- if __name__ == '__main__':
- # app.run(port=5002, debug=True)
- # Serve the app with gevent
- http_server = WSGIServer(('', 5000), app)
- http_server.serve_forever()
- `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement