-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (26 loc) · 813 Bytes
/
main.py
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
29
30
31
32
33
34
#!/usr/bin/python
# coding=utf-8
""" Image distortion application
:usage:
Flask application.
:authors
JP at 09/01/20
"""
from flask import Flask, send_file
from app.imaging import read_image, get_distortion_array, combine_distort_array, convert_distorted_image
# Create the Flask web application
app = Flask(__name__)
@app.route('/v1/image', methods=["GET"])
@app.route('/', methods=["GET"])
def get_image():
image = read_image('./images/logo.png')
dist = get_distortion_array(distortion_amount=3)
dist_img_array = combine_distort_array(image, dist)
out = convert_distorted_image(dist_img_array)
return send_file(out, mimetype='image/png')
def create_app():
"""Create the Flask application."""
return app
if __name__ == "__main__":
app = create_app()
app.run()