fix: fixed client side example
This commit is contained in:
parent
28d0f0268a
commit
9ed54121c6
4 changed files with 18 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
var express = require('express')
|
||||
var app = express.createServer()
|
||||
var app = express();//.createServer()
|
||||
var http = require('http')
|
||||
var fs = require('fs')
|
||||
var QRCode = require('../lib')
|
||||
|
@ -9,11 +9,19 @@ var Image = Canvas.Image
|
|||
|
||||
var path = require('path')
|
||||
|
||||
app.configure(function () {
|
||||
app.use(express.methodOverride())
|
||||
app.use(express.bodyParser())
|
||||
app.use(app.router)
|
||||
app.use(express.static(path.resolve(__dirname, '..')))
|
||||
//app.use(express.methodOverride())
|
||||
//app.use(express.bodyParser())
|
||||
// app.use(app.router)
|
||||
//app.use(express.static(path.resolve(__dirname, '..')))
|
||||
|
||||
app.get('/qrcode.js',(req,res)=>{
|
||||
res.set('content-type','text/javascript');
|
||||
fs.createReadStream(path.join(__dirname,'..','build','qrcode.js')).pipe(res)
|
||||
})
|
||||
|
||||
app.get('/qrcode.tosjis.js',(req,res)=>{
|
||||
res.set('content-type','text/javascript');
|
||||
fs.createReadStream(path.join(__dirname,'..','build','qrcode.tosjis.js')).pipe(res)
|
||||
})
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
|
@ -64,11 +72,6 @@ effectHandlers.bacon = function (args, cb) {
|
|||
this.image(args, cb)
|
||||
}
|
||||
|
||||
effectHandlers.baconBikini = function (args, cb) {
|
||||
args.src = path.join(__dirname, 'images', 'bacon-bikini.png')
|
||||
this.image(args, cb)
|
||||
}
|
||||
|
||||
effectHandlers.rounded = function (args, cb) {
|
||||
var canvas = new Canvas(200, 200)
|
||||
QRCode.toCanvas(canvas, args.text || '', function (err) {
|
||||
|
|
Binary file not shown.
Before ![]() (image error) Size: 398 KiB |
|
@ -1,5 +1,5 @@
|
|||
var QRCode = require('../lib')
|
||||
var connect = require('express')
|
||||
var http = require('http')
|
||||
|
||||
function testQRCode (req, res) {
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' })
|
||||
|
@ -31,5 +31,5 @@ function testQRCode (req, res) {
|
|||
})
|
||||
}
|
||||
|
||||
connect.createServer(testQRCode).listen(3030)
|
||||
http.createServer(testQRCode).listen(3030)
|
||||
console.log('test server started on port 3030')
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
"pretest": "npm run lint",
|
||||
"test": "node --throw-deprecation test.js",
|
||||
"build": "node build.js",
|
||||
"prepublish": "npm run build"
|
||||
"prepublish": "npm run build",
|
||||
"browser":"node examples/clientsideserver.js"
|
||||
},
|
||||
"bin": {
|
||||
"qrcode": "./bin/qrcode"
|
||||
|
|
Loading…
Reference in a new issue