RSS

Category Archives: Uncategorized

POST a file, read a JSON response

Here’s a trick to send a file to a server AND read a response from it, in the same context.
I used it with a Node.js server (Express + busboy) and it worked like a charm.

When using HTML forms, you can submit stuff to a server but you can’t read a response from it.
If you need some kind of “send data” → (do something server side) → “read response” it can be painful.

I wrote a workaround to manage this kind of situation. It is pretty simple:
– prepare a form as usual
– block the original event
– build an ajax request as a POST method

Here’s the code

Advertisements
 
Leave a comment

Posted by on 2017/07/14 in dev, Uncategorized

 

Tags: , ,

(another) handlebars template

I just started using loving gist.

This is a pretty basic Handlebars template, with its render engine.

 
Leave a comment

Posted by on 2017/06/12 in Uncategorized

 

Node.js v7 on my Pi

Straight to the code:

wget https://nodejs.org/dist/latest-v7.x/node-v7.10.0-linux-armv6l.tar.gz
tar -xvf node-v7.10.0-linux-armv6l.tar.gz
cd node-v7.10.0-linux-armv6l/
sudo cp -R * /usr/local/
 
Leave a comment

Posted by on 2017/05/09 in Uncategorized