def server_error(error=None): if error: err_logger.error("500: {}".format(error), exc_info=True) message = {"msg": "Server Error", "code": 500} return jsonify(message), 500 @app.errorhandler(404) def not_found(error=None): message = { 'code': 404, 'msg': 'Not Found: ' + request.url, } resp = jsonify(message) resp.status_code = 404 return resp @app.errorhandler(403) def Permission_denied(error=None): message = {"msg": "Authentication failed, permission denied.", "code": 403} return jsonify(message), 403 if __name__ == '__main__': from werkzeug.contrib.fixers import ProxyFix app.wsgi_app = ProxyFix(app.wsgi_app) app.run(host=config.GLOBAL["Host"], port=int(config.GLOBAL["Port"]), debug=True)
os.path.join(root_dir, 'python', 'fileCollection', 'backend', 'static', 'html'), 'index.html') # return app.send_file('static/html/index.html') @app.route('/result', methods=['POST', 'GET']) def get(): data = menu.menu_3() index = request.form['submit'].split(':')[0] album_name = request.form['menu' + index] # print("index : %s" % index) # print("index : %s" % album_name) # list = data[album_name] filelist = [ url_for('static', filename=album_name + '/' + album['filename']) for album in data.get(album_name, '') ] return render_template("result.html", list=filelist) @app.route('/album/<path:path>') def send_js(path): print(os.path.join('D:\\내사진\\Album 2017\\', path)) return Response( '<img src="/Album%202017/170110-%EC%8B%A0%EC%A3%BC%EC%BF%A0%EC%82%B0%EC%B1%85/20170106_223247_HDR.jpg">', mimetype="text/html") if __name__ == '__main__': app.run(debug=True)