File: image_demo.py

package info (click to toggle)
flask-openapi3 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,224 kB
  • sloc: python: 4,807; makefile: 14; javascript: 5
file content (23 lines) | stat: -rw-r--r-- 412 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
23
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2021/6/26 17:05

from flask import make_response

from flask_openapi3 import OpenAPI

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)