-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.py
More file actions
28 lines (19 loc) · 565 Bytes
/
Copy pathindex.py
File metadata and controls
28 lines (19 loc) · 565 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from io import BytesIO
from flask import Flask, request, send_file
from urlshot.screenshot import Screenshot
app = Flask(__name__)
@app.route('/api', methods=['GET'])
def take_screenshot():
url = request.args.get('url')
width = int(
request.args.get('width', 1024)
)
height = int(
request.args.get('height', 768)
)
screenshot = Screenshot.take(url, width, height)
return send_file(
BytesIO(screenshot), mimetype='image/png'
)
if __name__ == '__main__':
app.run(debug=True, port=5000)