from flask import Flask,request,make_response,redirect,url_for,render_template,jsonify from flask_cors import CORS from Jsonfile import JSONfile from ReverseProxied import ReverseProxied import emission data= JSONfile("chaine.json") app=Flask(__name__,static_folder = "dist/static",template_folder="dist") app.wsgi_app = ReverseProxied(app.wsgi_app) CORS(app) @app.route('/api/v1/ping', methods=['GET']) def ping_pong(): return jsonify('pong!') @app.route('/api/v1/chaine/', methods=['GET']) def get_chaine(num): return jsonify(data.get_chaine(num)) @app.route('/api/v1/chaine/', methods=['put']) def update_list(): status="data.parsechaine()" if(status=='ok'): return jsonify("OK") else: return make_response('Error during Chaine Update',500) @app.route('/api/v1/chaine//emission', methods=['GET']) def get_emmission(num): chaine=data.get_chaine(num) if (chaine == "numero de chaine inconnue"): return jsonify(chaine) else: return jsonify(emission.parse_emmission(chaine)) ##@app.errorhandler(404) ##def ma_page_404(error): ## return redirect("https://www.ducamps.win/404/404.html", 307) if __name__ == '__main__': app.run(debug=True)