Code Monkey home page Code Monkey logo

Comments (7)

moorereason avatar moorereason commented on May 22, 2024

Please better explain your scenario and use case. I bet you can solve this within the execute_command script when include-command-output-in-response is true.

from webhook.

actuariat avatar actuariat commented on May 22, 2024

OK, let's kepp it simple— every 5 minutes a new complicated image it is generated on the server, output.jpg

I need the webhook to display the latest image generated on the server, using webhook.

This is the setting:

{
    "id": "itst",
    "include-command-output-in-response": true,
    "response-headers": [
      {
        "name": "Content-Type",
        "value": "text/html"
      }
    ],
    "execute-command": "echo",
    "pass-arguments-to-command": [
      {
        "source": "string",
        "name": "<**meta1** http-equiv='Content-type' content='text/html; charset=utf-8'/><html style='height: 100%;'><head><title>test</title></head><body style='margin: 0px; height: 100%'><img style='-webkit-user-select:none; display:block; margin:auto; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);' **src=output.jpg**''></body></html>"
      }
    ]
}

from webhook.

moorereason avatar moorereason commented on May 22, 2024

Assuming a Linux host, try something like this:

{
    "id": "itst",
    "include-command-output-in-response": true,
    "response-headers": [
      {
        "name": "Content-Type",
        "value": "text/html"
      }
    ],
    "execute-command": "/path/to/showpage.sh",
    "pass-arguments-to-command": [
      {
        "source": "string",
        "name": "/path/to/output.jpg"
      }
    ]
}

showpage.sh:

#!/usr/bin/bash
echo -n '<**meta1** http-equiv="Content-type" content="text/html; charset=utf-8"/><html style="height: 100%;"><head><title>test</title></head><body style="margin: 0px; height: 100%"><img style="-webkit-user-select:none; display:block; margin:auto; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);" **src="data:/image/jpeg,'
base64 -w 0 $1
echo '**"></body></html>'

from webhook.

actuariat avatar actuariat commented on May 22, 2024

Thank you, I fix it like this, it works now:

#!/usr/bin/bash
echo -n '<meta http-equiv="Content-type" content="text/html; charset=utf-8"/><html style="height: 100%;"><head><title>test</title></head><body style="margin: 0px; height: 100%"><img style="-webkit-user-select:none; display:block; margin:auto; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);" src="data:image/jpeg;base64,'
base64 -w 0 $1
echo '"></body></html>'

Not particularly elegant; it clutters the logs by logging every single image in its entirety.

from webhook.

moorereason avatar moorereason commented on May 22, 2024

Not particularly elegant; it clutters the logs by logging every single image in its entirety.

Where is this being logged? Unless you're running webhook with debug enabled, it should not log the response body. Please explain.

from webhook.

actuariat avatar actuariat commented on May 22, 2024

I run it like this:

webhook -hooks wb.json -hotreload -logfile webhook.out -port 80&

I think anyone should run it like this. It is one of your strong points—at least for me was the deciding factor.

Maybe we should work on: command output, not to display the entire response body.

from webhook.

moorereason avatar moorereason commented on May 22, 2024

@actuariat,
I'm glad this issue is resolved for you.

I've opened a separate issue about adding the ability to control command output logging.

from webhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.