flask_server.py 542 B

12345678910111213141516171819202122
  1. from flask import Flask, request, render_template, make_response, redirect
  2. app = Flask(__name__)
  3. app.config["TEMPLATES_AUTO_RELOAD"] = True
  4. import command
  5. @app.route("/")
  6. def index():
  7. return render_template("index.html")
  8. @app.route("/tv/<cmd>")
  9. def action_tv(cmd):
  10. command.send_code(cmd, "tv")
  11. #return redirect("/", code=307)
  12. return "<p>Sent '{0}'</p>".format(cmd)
  13. @app.route("/mb/<cmd>")
  14. def action_mb(cmd):
  15. command.send_code(cmd, "mb")
  16. #return redirect("/", code=307)
  17. return "<p>Sent '{0}'</p>".format(cmd)