0

I have a html page under template\about\index.html

Is it possible to display an image who is located in the same path -> template\about\img.jpg ?? I have try many ways but didn't manage to make it happen.

I want to avoid the use of the static folder in this case.

Thanks.

SpongeB0B
  • 79
  • 1
  • 9

2 Answers2

0

[assume your application object is called app]

@app.route('/imgIFrame')

def imgIframe():
    with open('template/about/img.jpg') as fin:
        data = fin.read()
        ret = make_response(data, 200)
        ret.headers['Content-Type'] = 'img/jpeg'
        return ret

In your HTML you'll need an iframe populated by a call to that method and you should be golden.

hd1
  • 33,938
  • 5
  • 80
  • 91
0

You can create a config.py file

APP_ROOT = os.path.dirname(os.path.abspath(__file__))
APP_YOUR_IMAGE_DIRECTORY= os.path.join(APP_ROOT, 'template\about\')

and then you can import that path anywhere

from config import APP_YOUR_IMAGE