You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A REST API to generate portfolio-ready screenshots of your awesome web projects
4
4
5
5
## Description
6
6
7
7
Once a web project is done, it's time to document your hard work and show it off. _Portfoliofy_ makes that process easier by doing all the screenshots for you and assembling them together into portfolio-ready files.
8
8
9
-
As of v2.4.2, the following `OUTPUT` types can be generated:
9
+
As of v3.0.0-beta.1, the following `OUTPUT` types can be requested from exposed endpoints (see below):
10
10
11
-
*`OUTPUT_SCREENSHOTS`
12
-
* Four image files of screenshots taken in different window sizes mimicking the viewport of a desktop (2160x1360), a laptop (1440x900), a tablet (768x1024) and a smartphone (230x490).
13
-
* One image file of a full-page screenshot.
14
11
*`OUTPUT_MAIN`
15
-
* An image file of those screenshots, except the full-page one, overlaid on top of a schematic diagram and then collaged together. (See below for an example ouput.)
12
+
* An image file of screenshots taken from a "desktop", a "laptop", a "tablet" and a "smartphone", overlaid on top of a schematic diagram and collaged together. (See below for an example ouput.)
16
13
*`OUTPUT_BROWSER`
17
-
* An image file of the desktop screenshot overlaid on top of a schematic diagram. (Scroll to the bottom for an example ouput.)
14
+
* An image file of a screenshot taken from a "desktop", overlaid on top of a schematic diagram. (Scroll to the bottom for an example ouput.)
18
15
*`OUTPUT_MOBILES`
19
-
* An image file of the tablet and smartphone screenshots overlaid on top of a schematic diagram and paired together. (Scroll to the bottom for an example ouput.)
16
+
* An image file of screenshots from a "desktop" and a "laptop" overlaid on top of a schematic diagram and paired together. (Scroll to the bottom for an example ouput.)
20
17
*`OUTPUT_FULL`
21
-
* An image file of the full-page screenshot overlaid on top of a schematic diagram. (Scroll to the bottom for an example ouput.)
18
+
* An image file of a full-page screenshot overlaid on top of a schematic diagram. (Scroll to the bottom for an example ouput.)
22
19
*`OUTPUT_MOVIE`
23
-
* A scroll animation video of the full-page screenshot. (Scroll to the bottom for an example ouput.)
20
+
* A scroll animation video of a full-page screenshot. (Scroll to the bottom for an example ouput.)
21
+
*`OUTPUT_SCREENSHOTS`
22
+
* Plain screenshots taken from window sizes mimicking the viewport of a desktop (2160x1360), a laptop (1440x900), a tablet (768x1024) and a smartphone (230x490), requested separately.
23
+
* Plain full-page screenshot.
24
24
25
25
More coming soon!
26
26
@@ -37,11 +37,12 @@ ALL CONTENTS IN THIS REPO ARE FOR EDUCATIONAL PURPOSES ONLY.
At minimum change the `url`[parameter](https://github.com/ggeerraarrdd/portfoliofy#parameters) in `local_settings.py` to the webpage you want to portfoliofy.
55
-
56
-
Then run the following command:
55
+
Go into the project directory and execute the following command to run the live server:
57
56
58
57
```bash
59
-
python portfoliofy.py
58
+
uvicorn app.main:app --reload
60
59
```
61
60
62
-
The output files are stored in a subdirectory of the `output` directory.
61
+
## Documentations
62
+
63
+
The _Portfoliofy_ REST API was built using FastAPI, which comes with two documentation user interfaces:
64
+
65
+
*[Swagger UI](https://swagger.io/tools/swagger-ui/): served at `/docs`.
66
+
*[ReDoc](https://redocly.github.io/redoc/): served at `/redoc`.
67
+
68
+

69
+
_The Swagger UI for Portfoliofy served at `/docs`_
70
+
71
+
## Endpoints
72
+
73
+
`POST /main` - handles requests for `OUTPUT_MAIN`.
74
+
75
+
`POST /browser` - handles requests for `OUTPUT_BROWSER`.
76
+
77
+
`POST /mobiles` - handles requests for `OUTPUT_MOBILES`.
78
+
79
+
`POST /full` - handles requests for `OUTPUT_FULL`.
80
+
81
+
`POST /movie` - handles requests for `OUTPUT_MOVIE`.
82
+
83
+
`POST /screenshots/desktop` - handles requests for screenshots from a desktop viewport (2160x1360).
84
+
85
+
`POST /screenshots/laptop` - handles requests for screenshots from a laptop viewport (1440x900).
86
+
87
+
`POST /screenshots/tablet` - handles requests for screenshots from a tablet viewport (768x1024).
88
+
89
+
`POST /screenshots/smartphone` - handles requests for screenshots from a smartphone viewport (230x490).
90
+
91
+
`POST /screenshots/full` - handles requests for a full-page screenshot.
63
92
64
93
## Parameters
65
94
66
-
This is a list of parameters you can change in `local_settings.py`.
67
-
68
-
| Parameter | Type | Default value | Value range | Description |
| request | bool | True | True, False | If TRUE, requested output is processed. |
84
-
| format | string | png | png | Format of the final output. |
85
-
| doc_pad_h | int | 300 | 1 - 1000 | Left and right padding in pixels of final output. |
86
-
| doc_pad_v | int | 200 | 1 - 1000 | Top and bottom padding in pixels of final output. |
87
-
| doc_fill_color | string | #FFFFFF | '' | Background color of final output in 6-digit hex. |
88
-
| base_stroke_color | string | #23445D | '' | Stroke color of diagram in 6-digit hex. |
89
-
| base_fill_color | string | #BAC8D3 | '' | Fill color of diagram in 6-digit hex. |
90
-
91
-
### Notes
92
-
93
-
*`OUTPUT_MOVIE` currently will not be processed if the height of the full-page screenshot is >= 20,000px after it is resized to a width of 1280px.
94
-
*`OUTPUT_MOVIE` currently only accepts mp4 format.
95
-
96
-
### Example
97
-
98
-
This code will portfoliofy a webpage served on a web server running on a local computer. It only requests `OUTPUT_MAIN` and `OUTPUT_BROWSER` both in the default PNG format. `OUTPUT_MAIN`, `OUTPUT_MOBILES`, `OUTPUT_FULL` and `OUTPUT_VIDEO` will not be processed. But all `OUTPUT_SCREENSHOTS` will be saved. All other parameters remain set to their default values.
99
-
100
-
```python
101
-
user_input = {
102
-
"url": "http://localhost:5000/",
103
-
"wait": 2,
104
-
"screenshots": True,
105
-
"output_main": {
106
-
"request": True,
107
-
"format": "png",
108
-
"doc_pad_h": 300,
109
-
"doc_pad_v": 200,
110
-
"doc_fill_color": "#FFFFFF",
111
-
"base_stroke_color": "#23445D",
112
-
"base_fill_color": "#BAC8D3",
113
-
},
114
-
"output_browser": {
115
-
"request": True,
116
-
"format": "png",
117
-
"doc_pad_h": 300,
118
-
"doc_pad_v": 200,
119
-
"doc_fill_color": "#FFFFFF",
120
-
"base_stroke_color": "#23445D",
121
-
"base_fill_color": "#BAC8D3",
122
-
},
123
-
"output_mobiles": {
124
-
"request": False,
125
-
"format": "png",
126
-
"doc_pad_h": 300,
127
-
"doc_pad_v": 200,
128
-
"doc_fill_color": "#FFFFFF",
129
-
"base_stroke_color": "#23445D",
130
-
"base_fill_color": "#BAC8D3",
131
-
},
132
-
"output_full": {
133
-
"request": False,
134
-
"format": "png",
135
-
"doc_pad_h": 300,
136
-
"doc_pad_v": 200,
137
-
"doc_fill_color": "#FFFFFF",
138
-
"base_stroke_color": "#23445D",
139
-
"base_fill_color": "#BAC8D3",
140
-
},
141
-
"output_video": {
142
-
"request": False,
143
-
"format": "mp4",
144
-
"doc_pad_h": 300,
145
-
"doc_pad_v": 200,
146
-
"doc_fill_color": "#FFFFFF",
147
-
"base_stroke_color": "#23445D",
148
-
"base_fill_color": "#BAC8D3",
149
-
},
95
+
This is the request body schema for all endpoints.
96
+
97
+
| Parameter | Type | Default value | Value range | Description |
*The [tutorial](https://pillow.readthedocs.io/en/stable/handbook/tutorial.html) at Pillow's website.
159
+
*[Sanjeev Thiyagarajan](https://www.linkedin.com/in/sanjeev-thiyagarajan-690001163/)'s massive, 19-hour Python API Development [course](https://www.youtube.com/playlist?list=PL8VzFQ8k4U1IiGUWdBI7s9Y7dm-4tgCXJ) is `the` best online tutorial video I have watched not just on APIs but on any IT topic.
0 commit comments