forked from alvarcarto/url-to-pdf-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement security restriction options to allow limiting demo app
- Loading branch information
1 parent
4b15a12
commit 0400fa0
Showing
6 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,12 @@ and requests are direct connections to it. | |
|
||
## Examples | ||
|
||
*Note: the demo Heroku app runs on a free dyno which sleep after idle. | ||
A request to sleeping dyno may take even 30 seconds.* | ||
**⚠️ Restrictions ⚠️:** | ||
|
||
* For security reasons the urls have been restricted and HTML rendering is disabled. For full demo, run this app locally or deploy to Heroku. | ||
* The demo Heroku app runs on a free dyno which sleep after idle. A request to sleeping dyno may take even 30 seconds. | ||
|
||
|
||
|
||
**The most minimal example, render google.com** | ||
|
||
|
@@ -106,14 +110,18 @@ https://url-to-pdf-api.herokuapp.com/api/render?url=http://google.com&waitFor=in | |
|
||
**Render HTML sent in JSON body** | ||
|
||
*NOTE: Demo app has disabled html rendering for security reasons.* | ||
|
||
```bash | ||
curl -o html.pdf -XPOST -d'{"html": "<body>test</body>"}' -H"content-type: application/json" https://url-to-pdf-api.herokuapp.com/api/render | ||
curl -o html.pdf -XPOST -d'{"html": "<body>test</body>"}' -H"content-type: application/json" http://localhost:9000/api/render | ||
``` | ||
|
||
**Render HTML sent as text body** | ||
|
||
*NOTE: Demo app has disabled html rendering for security reasons.* | ||
|
||
```bash | ||
curl -o html.pdf -XPOST -d@page.html -H"content-type: text/html" https://url-to-pdf-api.herokuapp.com/api/render | ||
curl -o html.pdf -XPOST -d@test/resources/large.html -H"content-type: text/html" http://localhost:9000/api/render | ||
``` | ||
|
||
## API | ||
|
@@ -264,11 +272,11 @@ The only required parameter is `url`. | |
**Example:** | ||
|
||
```bash | ||
curl -o google.pdf -XPOST -d'{"url": "http://google.com"}' -H"content-type: application/json" https://url-to-pdf-api.herokuapp.com/api/render | ||
curl -o google.pdf -XPOST -d'{"url": "http://google.com"}' -H"content-type: application/json" http://localhost:9000/api/render | ||
``` | ||
|
||
```bash | ||
curl -o html.pdf -XPOST -d'{"html": "<body>test</body>"}' -H"content-type: application/json" https://url-to-pdf-api.herokuapp.com/api/render | ||
curl -o html.pdf -XPOST -d'{"html": "<body>test</body>"}' -H"content-type: application/json" http://localhost:9000/api/render | ||
``` | ||
|
||
### POST /api/render - (HTML) | ||
|
@@ -283,7 +291,7 @@ paremeter. | |
|
||
```bash | ||
curl -o receipt.html https://rawgit.com/wildbit/postmark-templates/master/templates_inlined/receipt.html | ||
curl -o html.pdf -XPOST [email protected] -H"content-type: text/html" https://url-to-pdf-api.herokuapp.com/api/render?pdf.scale=1 | ||
curl -o html.pdf -XPOST [email protected] -H"content-type: text/html" http://localhost:9000/api/render?pdf.scale=1 | ||
``` | ||
|
||
## Development | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters