testserver.py 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env python3
  2. from flask import Flask, Response, redirect, url_for, request
  3. import sys
  4. app = Flask(__name__)
  5. @app.route("/", methods=['GET'])
  6. def test_get1():
  7. return Response("OK", mimetype='text/plain')
  8. @app.route("/some/path")
  9. def test_get2():
  10. return Response("OK", mimetype='text/plain')
  11. @app.route("/redirect")
  12. def test_redirect():
  13. return redirect(url_for('test_get1'))
  14. @app.route("/double_redirect")
  15. def test_doubleredirect():
  16. return redirect(url_for('test_redirect'))
  17. @app.route("/post", methods=['POST'])
  18. def test_post():
  19. return request.get_data();
  20. @app.route("/put", methods=['PUT'])
  21. def test_put():
  22. return request.get_data();
  23. @app.route("/delete", methods=['DELETE'])
  24. def test_delete():
  25. return request.get_data();
  26. if __name__ == "__main__":
  27. if len(sys.argv) >= 2:
  28. app.run(debug=True, ssl_context=(sys.argv[1]+'/cert.pem', sys.argv[1]+'/key.pem'), port=5443)
  29. else:
  30. app.run(debug=True)