NodeJS Express — Serve generated index.html public file without saving it2019 Community Moderator ElectionNodeJS — Fork Child Process with function string instead of fileNodeJS / Express: what is “app.use”?What's the difference between app.use and app.get with express.static?serving static content with a cachall route - expressexpress js not serving static filesWhat's the better approach: serving static files with Express or nginx?Code doesn't serve my static html files in the publlic folderExpress File Serving and Static FilesHow do I serve static files for my node-js server which are in my application root directoryHow to make express serve static files from another upper directory?How to properly serve index.html from node / express app?
If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?
Relationship between sampajanna definitions in SN 47.2 and SN 47.35
Could this Scherzo by Beethoven be considered to be a fugue?
Is Manda another name for Saturn (Shani)?
Print a physical multiplication table
How could a scammer know the apps on my phone / iTunes account?
Have the tides ever turned twice on any open problem?
How to get the n-th line after a grepped one?
Violin - Can double stops be played when the strings are not next to each other?
Examples of transfinite towers
Aluminum electrolytic or ceramic capacitors for linear regulator input and output?
Is a party consisting of only a bard, a cleric, and a warlock functional long-term?
How to write cleanly even if my character uses expletive language?
Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?
Adventure Game (text based) in C++
"of which" is correct here?
Can a wizard cast a spell during their first turn of combat if they initiated combat by releasing a readied spell?
How can we have a quark condensate without a quark potential?
How to pronounce "I ♥ Huckabees"?
What favor did Moody owe Dumbledore?
Custom alignment for GeoMarkers
How do you talk to someone whose loved one is dying?
Math equation in non italic font
Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?
NodeJS Express — Serve generated index.html public file without saving it
2019 Community Moderator ElectionNodeJS — Fork Child Process with function string instead of fileNodeJS / Express: what is “app.use”?What's the difference between app.use and app.get with express.static?serving static content with a cachall route - expressexpress js not serving static filesWhat's the better approach: serving static files with Express or nginx?Code doesn't serve my static html files in the publlic folderExpress File Serving and Static FilesHow do I serve static files for my node-js server which are in my application root directoryHow to make express serve static files from another upper directory?How to properly serve index.html from node / express app?
When using express, the expectation is that you'll serve a public directory.
const app = express();
app.use('/', express.static('./public/'));
Is there a way I could serve a generated file instead? For my application, it would be much more convenient if I could build the index.html directly, then serve that 'file' directly from memory, without having to save it just to then serve it via 'use'.
node.js express web-applications server code-generation
add a comment |
When using express, the expectation is that you'll serve a public directory.
const app = express();
app.use('/', express.static('./public/'));
Is there a way I could serve a generated file instead? For my application, it would be much more convenient if I could build the index.html directly, then serve that 'file' directly from memory, without having to save it just to then serve it via 'use'.
node.js express web-applications server code-generation
add a comment |
When using express, the expectation is that you'll serve a public directory.
const app = express();
app.use('/', express.static('./public/'));
Is there a way I could serve a generated file instead? For my application, it would be much more convenient if I could build the index.html directly, then serve that 'file' directly from memory, without having to save it just to then serve it via 'use'.
node.js express web-applications server code-generation
When using express, the expectation is that you'll serve a public directory.
const app = express();
app.use('/', express.static('./public/'));
Is there a way I could serve a generated file instead? For my application, it would be much more convenient if I could build the index.html directly, then serve that 'file' directly from memory, without having to save it just to then serve it via 'use'.
node.js express web-applications server code-generation
node.js express web-applications server code-generation
asked Mar 6 at 20:44
KarricKarric
315215
315215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
the expectation is that you'll serve a public directory
I don't think that is the expectation at all. Many applications just use routes instead making a REST micro service.
There are two ways you can do what you want to do.
Use a templating engine with NodeJS and just
res.render()
the template. Check this out for more information, even though the article is using.pug
you can use these ones as well. Popular ones are ejs, handlebarsapp.get('/', function (req, res)
res.render('index', title: 'Hey', message: 'Hello there!' )
)Or you can write everything inside
res.send()
for example:app.get('/', function (req, res)
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
res.send('<h1>This is the response</h1>');
);
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031856%2fnodejs-express-serve-generated-index-html-public-file-without-saving-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
the expectation is that you'll serve a public directory
I don't think that is the expectation at all. Many applications just use routes instead making a REST micro service.
There are two ways you can do what you want to do.
Use a templating engine with NodeJS and just
res.render()
the template. Check this out for more information, even though the article is using.pug
you can use these ones as well. Popular ones are ejs, handlebarsapp.get('/', function (req, res)
res.render('index', title: 'Hey', message: 'Hello there!' )
)Or you can write everything inside
res.send()
for example:app.get('/', function (req, res)
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
res.send('<h1>This is the response</h1>');
);
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
add a comment |
the expectation is that you'll serve a public directory
I don't think that is the expectation at all. Many applications just use routes instead making a REST micro service.
There are two ways you can do what you want to do.
Use a templating engine with NodeJS and just
res.render()
the template. Check this out for more information, even though the article is using.pug
you can use these ones as well. Popular ones are ejs, handlebarsapp.get('/', function (req, res)
res.render('index', title: 'Hey', message: 'Hello there!' )
)Or you can write everything inside
res.send()
for example:app.get('/', function (req, res)
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
res.send('<h1>This is the response</h1>');
);
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
add a comment |
the expectation is that you'll serve a public directory
I don't think that is the expectation at all. Many applications just use routes instead making a REST micro service.
There are two ways you can do what you want to do.
Use a templating engine with NodeJS and just
res.render()
the template. Check this out for more information, even though the article is using.pug
you can use these ones as well. Popular ones are ejs, handlebarsapp.get('/', function (req, res)
res.render('index', title: 'Hey', message: 'Hello there!' )
)Or you can write everything inside
res.send()
for example:app.get('/', function (req, res)
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
res.send('<h1>This is the response</h1>');
);
the expectation is that you'll serve a public directory
I don't think that is the expectation at all. Many applications just use routes instead making a REST micro service.
There are two ways you can do what you want to do.
Use a templating engine with NodeJS and just
res.render()
the template. Check this out for more information, even though the article is using.pug
you can use these ones as well. Popular ones are ejs, handlebarsapp.get('/', function (req, res)
res.render('index', title: 'Hey', message: 'Hello there!' )
)Or you can write everything inside
res.send()
for example:app.get('/', function (req, res)
//set the appropriate HTTP header
res.setHeader('Content-Type', 'text/html');
//send multiple responses to the client
res.send('<h1>This is the response</h1>');
);
answered Mar 6 at 21:36
Aritra ChakrabortyAritra Chakraborty
2,41311015
2,41311015
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
add a comment |
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
I'm looking for something similar with forking a child process; directly pass the module instead of a filepath. If you can help with that too, I'd greatly appreciate it: stackoverflow.com/questions/55048262/…
– Karric
Mar 7 at 16:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031856%2fnodejs-express-serve-generated-index-html-public-file-without-saving-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown