C:/Users/Atul/AppData/Local/GitHub/PortableGit_015aa71ef18c047ce8509ffb2f9e4bb0e3e73f13/shot is a POST endpoint instead of GET.
This commit is contained in:
Родитель
cbb793860e
Коммит
9e8a990dfd
|
@ -1,6 +1,7 @@
|
|||
var spawn = require('child_process').spawn;
|
||||
var fs = require('fs');
|
||||
var express = require('express');
|
||||
var bodyParser = require('body-parser');
|
||||
|
||||
var app = express();
|
||||
|
||||
|
@ -12,10 +13,14 @@ app.get('/', function(req, res, next) {
|
|||
fs.createReadStream(__dirname + '/index.html').pipe(res);
|
||||
});
|
||||
|
||||
app.get('/shot', function(req, res, next) {
|
||||
var html = (req.query.html || '').trim();
|
||||
app.post('/shot', bodyParser.urlencoded({
|
||||
extended: false
|
||||
}), function(req, res, next) {
|
||||
var html = (req.body.html || '').trim();
|
||||
if (!html) return res.sendStatus(204);
|
||||
res.type('image/png');
|
||||
res.set('Content-Disposition',
|
||||
'attachment; filename="awesome-thing.png"');
|
||||
spawn(process.execPath, [RENDER, html]).stdout.pipe(res);
|
||||
});
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<h1>HTMLShot</h1>
|
||||
<p>Paste some HTML in the text field below and we'll give you a
|
||||
handy screenshot.</p>
|
||||
<form method="GET" action="shot">
|
||||
<form method="POST" action="shot">
|
||||
<textarea name="html" rows="25" cols="80" placeholder="Paste HTML here"></textarea>
|
||||
<br>
|
||||
<button type="Submit">Submit</button>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"express": "4.10.7"
|
||||
"express": "4.10.7",
|
||||
"body-parser": "^1.10.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче