Closed noxomix closed 3 years ago
It returns HTTPResponse
object. You can test a lot of things with Huginns interactive mode, like so:
[amok@ubiquitous](2/0)~/(work)$ huginn -q
huginn[0]> r = net.get( "https://codestation.org/" )
Class `HTTPResponse` does not have `code` method.
huginn[1]> type( r )
net.HTTPResponse
huginn[2]> //doc Network.HTTPResponse
Network.HTTPResponse - The HTTPResponse class is representing a response to Network.get(...) request
Class Network.HTTPResponse has following members:https://huginn.org/?h-action=bar-hgnref&hgnref=hgnref-network&huginn=huginn-reference&menu=submenu-project&page=projects&project=huginn&z=#sample&
+ filename
+ lastModified
+ mimeType
+ stream
huginn[3]> algo.materialize( r.stream, os.stdout() )
...
Network.HTTPResponse
is also described here:
https://huginn.org/?h-action=bar-hgnref&hgnref=hgnref-network&huginn=huginn-reference&menu=submenu-project&page=projects&project=huginn&z=#sample&
Ah yes logic ^^
because this returns
Yes. Interactive mode automatically performs conversion to code()
form results of an expression.
To do the same inside the script you need this (canonical form) code:
print( "{}\n".format( val ) );
Still, not all Huginn classes have proper interface implemented, so for Network.HTTPResponse
it will not work too.
It works::
Thank you very much.
One other thing: in your documentration the "use" link redirects to "observe" -- so how can I "use" / include other files ?? ^^
oh, I see my mistake
Isset normal that after os.exec() my code execution stops? exits?
because I wont to create a sleep() function, that I can create a While-loop wich runs every second 1-times hm...
ahh found it in datetime.sleep .. hard to find ^^
os.exec()
has the same semantics as exec()
in other programming languages, it replaces process image with executed program.
os.spawn()
allows running programs concurrently with Huginn script.
Yes, DateTime
might not be the best place for sleep()
function ;)
Also can I configure in Network.get()
a specific Port ?? my webapp is listening on port 3000 for example.
Okay Edit: I don't know why, but the .get() method doesn't accept NodeJS applications (on port 80/443/8080/3000 tested) I don't know why but only apache / nginx sites where displayed.
net.get("https://app.host.net:3000/")
yes thats doesnt work for me. I dont know why but he's Timing out, (in the last hour Ive create 2 NodeJS servers on different VPS servers :D
If you give me the link I will debug it on Monday. Understanding privacy concerns you can PM at https://gitter.im/codestation_org/huginn
I'll send you the Link tomorrow thx
Works for me, but I have fixed two bugs (one could be probably related to your issue) yesterday, so you can try apt-get update && apt-get dist-upgrade
.
Nice :)
And one other Question: There isn't a way to create a "POST" to RestAPI/httpRecource right??
You could do it manually with c = net.connect(...); c.write...
, but proper solution would be to implement missing functionality in underlying library. I could look into it.
There is a new Huginn function: Network.post()
, used like so:
respRaw = net.post("http://httpbin.org/post", {"elems":[1,2,3]});
resp = json.load(respRaw.stream);
Nice Thank you =)
How can I print a recource wich I get? So I want to print the HTML of a Page wich Ive get("https://url.end"), but what does .get() returns? It is not a string, because I cant print it.
HM