endpoint.py 528 B

123456789101112131415161718
  1. import time
  2. from typing import Mapping
  3. from werkzeug import Request, Response
  4. from dify_plugin import Endpoint
  5. class {{ .PluginName | SnakeToCamel }}Endpoint(Endpoint):
  6. def _invoke(self, r: Request, values: Mapping, settings: Mapping) -> Response:
  7. """
  8. Invokes the endpoint with the given request.
  9. """
  10. def generator():
  11. for i in range(10):
  12. time.sleep(1)
  13. yield f"{i} <br>"
  14. return Response(generator(), status=200, content_type="text/html")