File: image_demo.py

package info (click to toggle)
flask-openapi3 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,976 kB
  • sloc: python: 4,754; sh: 17; makefile: 15; javascript: 5
file content (22 lines) | stat: -rw-r--r-- 411 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2021/6/26 17:05

from flask_openapi3 import OpenAPI
from flask import make_response

app = OpenAPI(__name__)


@app.get('/image')
def get_image():
    with open("../docs/images/openapi.png", "rb") as f:
        content = f.read()

    r = make_response(content)
    r.mimetype = 'image/png'
    return r


if __name__ == '__main__':
    app.run(debug=True)