Re: [racket-users] Sending RESTful Commands using Racket
On Jun 17, 2015, at 11:38 AM, bruc...@gmail.com wrote: Thanks so much; however, I'm still having trouble getting the lights to respond. I had to alter your example somewhat, because Racket was complaining about an in-string: contract violation. The following seems to work: Oops forgot to cc: group: Going back to your original message, it appears that the data was encoded as JSON, not using a urlencoding (that would make sense for a GET, but not for a PUT or POST). Try using this code to generate the data: #lang racket (require json) (jsexpr-string (hash 'on #t 'bri 170 'ct 500)) Let me know if you want me to stuff it into the http-sendrecv call. John (http-sendrecv 192.168.1.95 /api/username/lights/1/state #:method 'PUT #:data (alist-form-urlencoded (list (cons 'bri 1) (cons 'ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) However, instead of affecting the light, I just get the following on the REPL: #HTTP/1.1 200 OK '(#Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 #Pragma: no-cache #Expires: Mon, 1 Aug 2011 09:00:00 GMT #Connection: close #Access-Control-Max-Age: 3600 #Access-Control-Allow-Origin: * #Access-Control-Allow-Credentials: true #Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD #Access-Control-Allow-Headers: Content-Type #Content-type: application/json) #input-port:pipe I've also tried sending the message using: #:data (form-urlencoded-encode \bri\: 1) and changing the #:headers to '(Content-Type: application/json) Any thoughts? My best, Bruce On Wednesday, June 17, 2015 at 11:35:32 AM UTC-4, Alexis King wrote: You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 On Jun 17, 2015, at 7:57 AM, Bruce wrote: Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Sending RESTful Commands using Racket
Thanks so much; however, I'm still having trouble getting the lights to respond. I had to alter your example somewhat, because Racket was complaining about an in-string: contract violation. The following seems to work: (http-sendrecv 192.168.1.95 /api/username/lights/1/state #:method 'PUT #:data (alist-form-urlencoded (list (cons 'bri 1) (cons 'ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) However, instead of affecting the light, I just get the following on the REPL: #HTTP/1.1 200 OK '(#Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 #Pragma: no-cache #Expires: Mon, 1 Aug 2011 09:00:00 GMT #Connection: close #Access-Control-Max-Age: 3600 #Access-Control-Allow-Origin: * #Access-Control-Allow-Credentials: true #Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD #Access-Control-Allow-Headers: Content-Type #Content-type: application/json) #input-port:pipe I've also tried sending the message using: #:data (form-urlencoded-encode \bri\: 1) and changing the #:headers to '(Content-Type: application/json) Any thoughts? My best, Bruce On Wednesday, June 17, 2015 at 11:35:32 AM UTC-4, Alexis King wrote: You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 On Jun 17, 2015, at 7:57 AM, Bruce wrote: Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Sending RESTful Commands using Racket
On Jun 17, 2015, at 8:35 AM, Alexis King lexi.lam...@gmail.com wrote: You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 Wait… http-client? That’s *way* better than all of the post-pure-port stuff I’ve been doing. How long has this been around? Okay, I probably don’t want to know. Many thanks! John Clements -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket rendering issues OS X
One data point: I’m using DrRacket version 6.2.0.4--2015-06-08 with OS X Version 10.9.5, and if I remember correctly it was a Racket plus Tests 64-bit installation. I tried those steps, and it worked fine, with no weird black areas, though I do remember occasionally getting similar small black areas in the past, covering just the tab bar or something like that, and when I moved my mouse over it it fixed itself? I’m not sure if I remember that correctly, and I’m not sure if that could be related to what you got, because that wasn’t with full screen or the mission control screen, and I could not produce that consistently. On Jun 17, 2015, at 12:25 PM, Andrew Kent andmk...@indiana.edu wrote: Good day all! First, I just wanted to say DrRacket is *amazing* and thank all who have helped it become what it is today! I'm currently using it to work on Typed Racket and it is a godsend. Right now, unfortunately, I am having some problems w/ DrRacket rendering in OS X -- I am getting large black areas appearing in full screen mode in DrRacket. They seem pretty serious/severe, and I was curious if anyone else has seen this behavior? PDF w/ screenshots some attempt to describe problem(s): https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing Steps that seem to recreate issue: 1) Open DrRacket 2) Make it full screen by clicking green button at top left of DrRacket 3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on touchpad) 4) Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon touchpad) nd 5) Repeat 3-4 a couple times (after the 2 time it seemed to consistently happen on my machine) - This worked whether or not I was plugged into the external monitor - the snapshots reproduced the issue on were the Racket plus Tests | Mac OS X | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b) version 6.2.0.4 (20150617-97827ac) - I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a early 2013 13” MacBook Air Best, Andrew -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket rendering issues OS X
On Wednesday, June 17, 2015 at 3:10:51 PM UTC-4, Alex Knauth wrote: One data point: I’m using DrRacket version 6.2.0.4--2015-06-08 with OS X Version 10.9.5, and if I remember correctly it was a Racket plus Tests 64-bit installation. I tried those steps, and it worked fine, with no weird black areas, though I do remember occasionally getting similar small black areas in the past, covering just the tab bar or something like that, and when I moved my mouse over it it fixed itself? I’m not sure if I remember that correctly, and I’m not sure if that could be related to what you got, because that wasn’t with full screen or the mission control screen, and I could not produce that consistently. On Jun 17, 2015, at 12:25 PM, Andrew Kent andm...@indiana.edu wrote: Good day all! First, I just wanted to say DrRacket is *amazing* and thank all who have helped it become what it is today! I'm currently using it to work on Typed Racket and it is a godsend. Right now, unfortunately, I am having some problems w/ DrRacket rendering in OS X -- I am getting large black areas appearing in full screen mode in DrRacket. They seem pretty serious/severe, and I was curious if anyone else has seen this behavior? PDF w/ screenshots some attempt to describe problem(s): https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing Steps that seem to recreate issue: 1) Open DrRacket 2) Make it full screen by clicking green button at top left of DrRacket 3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on touchpad) 4) Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon touchpad) nd 5) Repeat 3-4 a couple times (after the 2 time it seemed to consistently happen on my machine) - This worked whether or not I was plugged into the external monitor - the snapshots reproduced the issue on were the Racket plus Tests | Mac OS X | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b) version 6.2.0.4 (20150617-97827ac) - I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a early 2013 13” MacBook Air Best, Andrew -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. Additional note/update: When I was writing up the bug description those steps _were_ working consistently for me. Now, however, they do not... but somewhat erratically jumping workspaces left to right (I have Powerpoint full screened at the moment as well) mixed w/ some Mission Control access can cause it. So, I can't figure out how to do it 100% consistently, but it is definitely a reoccurring issue and sometimes I end up just having to close DrRacket to make it go away. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] http-sendrecv puts ##f in post-bytes if unspecified?
It appears to me that if you call http-sendrecv with a method of ‘POST, but fail to specify body bytes, that the request goes out with the two-byte string “#f” as the body. I can’t imagine that this would often be the right thing. Wouldn’t it make more sense just to signal an error if the method is ‘POST and no body bytes are specified? Thanks! John -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] DrRacket rendering issues OS X
At Wed, 17 Jun 2015 12:35:36 -0700 (PDT), Andrew Kent wrote: On Wednesday, June 17, 2015 at 3:10:51 PM UTC-4, Alex Knauth wrote: One data point: I’m using DrRacket version 6.2.0.4--2015-06-08 with OS X Version 10.9.5, and if I remember correctly it was a Racket plus Tests 64-bit installation. I tried those steps, and it worked fine, with no weird black areas, though I do remember occasionally getting similar small black areas in the past, covering just the tab bar or something like that, and when I moved my mouse over it it fixed itself? I’m not sure if I remember that correctly, and I’m not sure if that could be related to what you got, because that wasn’t with full screen or the mission control screen, and I could not produce that consistently. On Jun 17, 2015, at 12:25 PM, Andrew Kent andm...@indiana.edu wrote: Good day all! First, I just wanted to say DrRacket is *amazing* and thank all who have helped it become what it is today! I'm currently using it to work on Typed Racket and it is a godsend. Right now, unfortunately, I am having some problems w/ DrRacket rendering in OS X -- I am getting large black areas appearing in full screen mode in DrRacket. They seem pretty serious/severe, and I was curious if anyone else has seen this behavior? PDF w/ screenshots some attempt to describe problem(s): https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing Steps that seem to recreate issue: 1) Open DrRacket 2) Make it full screen by clicking green button at top left of DrRacket 3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on touchpad) 4) Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon touchpad) nd 5) Repeat 3-4 a couple times (after the 2 time it seemed to consistently happen on my machine) - This worked whether or not I was plugged into the external monitor - the snapshots reproduced the issue on were the Racket plus Tests | Mac OS X | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b) version 6.2.0.4 (20150617-97827ac) - I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a early 2013 13” MacBook Air Best, Andrew Additional note/update: When I was writing up the bug description those steps _were_ working consistently for me. Now, however, they do not... but somewhat erratically jumping workspaces left to right (I have Powerpoint full screened at the moment as well) mixed w/ some Mission Control access can cause it. So, I can't figure out how to do it 100% consistently, but it is definitely a reoccurring issue and sometimes I end up just having to close DrRacket to make it go away. I haven't been able to replicate the problem, but I'm also using Mavericks. This problem could easily be specific to Yosemite, and I'll check when I get back to my Yosemite machine in a couple of weeks. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Sending RESTful Commands using Racket
John, Thank you so much. That solved the problem of controlling the lights. However, I still can't figure out how to get at the response from the Hue Bridge. I should be receiving: [ {success:{/lights/1/state/on:true}}, {success:{/lights/1/state/bri:170}}, {success:{/lights/1/state/ct:500}} ] I'm having the same problem when I use GET to inquire about the state of the lights. My best, Bruce On Wednesday, June 17, 2015 at 2:50:36 PM UTC-4, johnbclements wrote: On Jun 17, 2015, at 11:38 AM, Bruce wrote: Thanks so much; however, I'm still having trouble getting the lights to respond. I had to alter your example somewhat, because Racket was complaining about an in-string: contract violation. The following seems to work: Oops forgot to cc: group: Going back to your original message, it appears that the data was encoded as JSON, not using a urlencoding (that would make sense for a GET, but not for a PUT or POST). Try using this code to generate the data: #lang racket (require json) (jsexpr-string (hash 'on #t 'bri 170 'ct 500)) Let me know if you want me to stuff it into the http-sendrecv call. John (http-sendrecv 192.168.1.95 /api/username/lights/1/state #:method 'PUT #:data (alist-form-urlencoded (list (cons 'bri 1) (cons 'ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) However, instead of affecting the light, I just get the following on the REPL: #HTTP/1.1 200 OK '(#Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 #Pragma: no-cache #Expires: Mon, 1 Aug 2011 09:00:00 GMT #Connection: close #Access-Control-Max-Age: 3600 #Access-Control-Allow-Origin: * #Access-Control-Allow-Credentials: true #Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD #Access-Control-Allow-Headers: Content-Type #Content-type: application/json) #input-port:pipe I've also tried sending the message using: #:data (form-urlencoded-encode \bri\: 1) and changing the #:headers to '(Content-Type: application/json) Any thoughts? My best, Bruce On Wednesday, June 17, 2015 at 11:35:32 AM UTC-4, Alexis King wrote: You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 On Jun 17, 2015, at 7:57 AM, Bruce wrote: Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Sending RESTful Commands using Racket
The http-sendrecv function returns three values: status : bytes? header : (listof bytes?) response : input-port? You need to look at the third one for the response. You could pass it to read-json or you could do port-string or anything else that you can do with an input port. Jay On Wed, Jun 17, 2015 at 5:14 PM, bruc...@gmail.com wrote: John, Thank you so much. That solved the problem of controlling the lights. However, I still can't figure out how to get at the response from the Hue Bridge. I should be receiving: [ {success:{/lights/1/state/on:true}}, {success:{/lights/1/state/bri:170}}, {success:{/lights/1/state/ct:500}} ] I'm having the same problem when I use GET to inquire about the state of the lights. My best, Bruce On Wednesday, June 17, 2015 at 2:50:36 PM UTC-4, johnbclements wrote: On Jun 17, 2015, at 11:38 AM, Bruce wrote: Thanks so much; however, I'm still having trouble getting the lights to respond. I had to alter your example somewhat, because Racket was complaining about an in-string: contract violation. The following seems to work: Oops forgot to cc: group: Going back to your original message, it appears that the data was encoded as JSON, not using a urlencoding (that would make sense for a GET, but not for a PUT or POST). Try using this code to generate the data: #lang racket (require json) (jsexpr-string (hash 'on #t 'bri 170 'ct 500)) Let me know if you want me to stuff it into the http-sendrecv call. John (http-sendrecv 192.168.1.95 /api/username/lights/1/state #:method 'PUT #:data (alist-form-urlencoded (list (cons 'bri 1) (cons 'ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) However, instead of affecting the light, I just get the following on the REPL: #HTTP/1.1 200 OK '(#Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 #Pragma: no-cache #Expires: Mon, 1 Aug 2011 09:00:00 GMT #Connection: close #Access-Control-Max-Age: 3600 #Access-Control-Allow-Origin: * #Access-Control-Allow-Credentials: true #Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD #Access-Control-Allow-Headers: Content-Type #Content-type: application/json) #input-port:pipe I've also tried sending the message using: #:data (form-urlencoded-encode \bri\: 1) and changing the #:headers to '(Content-Type: application/json) Any thoughts? My best, Bruce On Wednesday, June 17, 2015 at 11:35:32 AM UTC-4, Alexis King wrote: You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 On Jun 17, 2015, at 7:57 AM, Bruce wrote: Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy http://jeapostrophe.github.io Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great. - DC 64:33 -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] web-server/insta restart
As far as I know, there's nothing in DrRacket for it to Stop and then Start again when you save the file. It's fairly easy to that in Emacs, which I do when I'm working on stuff like that (actually, I have it so my Start command includes SaveStop.) If you are expecting the continuations and other saved state to update, you should read the FAQ on this: http://docs.racket-lang.org/web-server/faq.html?q=faq#%28part._update-servlets%29 Jay On Wed, Jun 17, 2015 at 10:11 AM, mail.tas...@gmail.com wrote: Hi, how can I make the already run server restart automatically each time I save the file? In scala for example ~run is used to get this benefit. Thanks in advance -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy http://jeapostrophe.github.io Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great. - DC 64:33 -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Sending RESTful Commands using Racket
If you're on linux, one dirty trick you could try is to start up a local web server like netcat to just listen on the HTTP port and show you the request that's happening: nc -l -p 80 Then, point Curl and your Racket script to localhost and compare the request sent by each. bruc...@gmail.com writes: John, Thank you so much. That solved the problem of controlling the lights. However, I still can't figure out how to get at the response from the Hue Bridge. I should be receiving: [ {success:{/lights/1/state/on:true}}, {success:{/lights/1/state/bri:170}}, {success:{/lights/1/state/ct:500}} ] I'm having the same problem when I use GET to inquire about the state of the lights. My best, Bruce On Wednesday, June 17, 2015 at 2:50:36 PM UTC-4, johnbclements wrote: On Jun 17, 2015, at 11:38 AM, Bruce wrote: Thanks so much; however, I'm still having trouble getting the lights to respond. I had to alter your example somewhat, because Racket was complaining about an in-string: contract violation. The following seems to work: Oops forgot to cc: group: Going back to your original message, it appears that the data was encoded as JSON, not using a urlencoding (that would make sense for a GET, but not for a PUT or POST). Try using this code to generate the data: #lang racket (require json) (jsexpr-string (hash 'on #t 'bri 170 'ct 500)) Let me know if you want me to stuff it into the http-sendrecv call. John (http-sendrecv 192.168.1.95 /api/username/lights/1/state #:method 'PUT #:data (alist-form-urlencoded (list (cons 'bri 1) (cons 'ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) However, instead of affecting the light, I just get the following on the REPL: #HTTP/1.1 200 OK '(#Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 #Pragma: no-cache #Expires: Mon, 1 Aug 2011 09:00:00 GMT #Connection: close #Access-Control-Max-Age: 3600 #Access-Control-Allow-Origin: * #Access-Control-Allow-Credentials: true #Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD #Access-Control-Allow-Headers: Content-Type #Content-type: application/json) #input-port:pipe I've also tried sending the message using: #:data (form-urlencoded-encode \bri\: 1) and changing the #:headers to '(Content-Type: application/json) Any thoughts? My best, Bruce On Wednesday, June 17, 2015 at 11:35:32 AM UTC-4, Alexis King wrote: You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 On Jun 17, 2015, at 7:57 AM, Bruce wrote: Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] web-server/insta restart
Hi, how can I make the already run server restart automatically each time I save the file? In scala for example ~run is used to get this benefit. Thanks in advance -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Sending RESTful Commands using Racket
Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Sending RESTful Commands using Racket
You probably want to use the net/http-client library, specifically the http-sendrecv function. I’m not 100% sure, but I’d guess that the equivalent Racket code for your curl command would look something like this. (require net/http-client net/uri-codec) (http-sendrecv 192.168.1.20 /api/username/lights/8/state #:method 'PUT #:data (alist-form-urlencoded '((on #t) (bri 170) (ct 500))) #:headers '(Content-Type: application/x-www-form-urlencoded)) See http://docs.racket-lang.org/net/http-client.html#%28def._%28%28lib._net%2Fhttp-client..rkt%29._http-sendrecv%29%29 On Jun 17, 2015, at 7:57 AM, bruc...@gmail.com wrote: Hello, I'm new to programming, so patience is appreciated. I'm writing a simple program in Racket to control Phillip Hue Bulbs in a performance environment. Phillips has a simple RESTful API and I'm looking for the Racket commands or library to send the commands. Previously I've used AppleScript to launch bash curl commands, like: curl -x PUT -d '{on:true,bri:170,ct:500}' http://192.168.1.20/api/username/lights/8/state Is there an easy way to send a similar message in Racket? Thank you, Bruce -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] DrRacket rendering issues OS X
Good day all! First, I just wanted to say DrRacket is *amazing* and thank all who have helped it become what it is today! I'm currently using it to work on Typed Racket and it is a godsend. Right now, unfortunately, I am having some problems w/ DrRacket rendering in OS X -- I am getting large black areas appearing in full screen mode in DrRacket. They seem pretty serious/severe, and I was curious if anyone else has seen this behavior? PDF w/ screenshots some attempt to describe problem(s): https://drive.google.com/file/d/0B-HcU1nZPrwJWXFNbEdOV0doeUE/view?usp=sharing Steps that seem to recreate issue: 1) Open DrRacket 2) Make it full screen by clicking green button at top left of DrRacket 3) Open OS X ‘Mission Control’ (cmd+up or 3-finger-swipe up on touchpad) 4) Close OS X ‘Mission Control’ (cmd+down or 3-finger-swipe downon touchpad) nd 5) Repeat 3-4 a couple times (after the 2 time it seemed to consistently happen on my machine) - This worked whether or not I was plugged into the external monitor - the snapshots reproduced the issue on were the Racket plus Tests | Mac OS X | 32-bit Intel distribution for version 6.2.0.4 (20150609-bf12a2b) version 6.2.0.4 (20150617-97827ac) - I’m running the latest OS X Yosemite (Version 10.10.3 (14D136)) on a early 2013 13” MacBook Air Best, Andrew -- You received this message because you are subscribed to the Google Groups Racket Users group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.