Skip to content

alexventuraio/qr_codes_sails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR example in SailsJS

a Sails application


Description

In this example I show you how to send a QR code via HTTP request in two simple steps:

  1. Add a route to the controller you want to use like
  'GET /qr': 'QrController.index',
  'GET /qr2': 'QrController.showqr'
  1. Require the Node module in the controller, in this case qr-image
  var qr = require('qr-image');

Also you can retreive the data you want to embed in the QR code by the parameters in the request like:

  var text = req.param('data_to_embed');

  var img = qr.image(text);
  res.writeHead(200, {'Content-Type': 'image/png'});
  img.pipe(res);

How to

Just fork or download the repository and enter the folder using cd qr_example and run the following command to install all the dependencies:

  npm install

Then run the following command to execute the Sails project:

  sails lift

Go to http://localhost:1337/qr or http://localhost:1337/qr2 to see the code rendering on the browser or using Postman it will work too.


I hope it could be useful, Follow me on Twitter @Lexynux!

About

Sending QR codes via HTTP request in an API project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published