jpodwys / express-stream Goto Github PK
View Code? Open in Web Editor NEWResponse streaming middleware for Express 4.
Home Page: https://express-stream-demo.herokuapp.com/
License: MIT License
Response streaming middleware for Express 4.
Home Page: https://express-stream-demo.herokuapp.com/
License: MIT License
Im getting this error on chrome. My code:
let express = require("express");
let app = express();
let ejs = require('ejs');
let stream = require('express-stream');
app.set("view engine", "ejs");
app.set('port', (process.env.PORT || 5000));
app.use(express.static("public"));
stream.useAllAutoTags(true);
stream.streamBefore('pre-body-view');
stream.streamAfter('post-body-view');
module.exports.response = ()=>{
app.get("/",stream.stream(),(req,res)=>{
res.render("index");
res.close();
});
app.get("/#",stream.stream(),(req,res)=>{
res.render("index");
});
app.get("/sidebar",stream.stream(),(req,res)=>{
res.render("sidebar");
});
app.get("/local",stream.stream(),(req,res)=>{
res.render("local");
});
app.get("/cardapio",stream.stream(),(req,res)=>{
res.render("cardapio");
});
app.get("/ajax",stream.stream(),(req,res)=>{
res.render("../public/data/index");
console.log("ajax");
});
app.get("/ajaxlocal",stream.stream(),(req,res)=>{
res.render("../public/data/local");
});
app.get("/ajaxcardapio",stream.stream(),(req,res)=>{
res.render("../public/data/cardapio");
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
}
Hi!
Your streaming implementation looks great for streaming server-side rendered templates! Do you also cache the compiled templates like express does by default?
hey,
I am getting this error TypeError: res.close is not a function
.
There is nothing much in code actually.
home: async function (req, res) {
res.stream("head");
res.close();
},
Please help.
Have you checked with pug, I think there may be some problem when using res.end() and the response is not flushed with the last chunk, the browser hangs for a long time without any error and the last chunk is not sent to the browser.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.