Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html with images #29

Open
herrwoland opened this issue Dec 21, 2022 · 1 comment
Open

Html with images #29

herrwoland opened this issue Dec 21, 2022 · 1 comment

Comments

@herrwoland
Copy link

herrwoland commented Dec 21, 2022

Hello,
I am a beginner with programming but seems to me that there is no way to put image files in the html?
I tried this but it's not working:
@app.route('/images/<fn>')
async def images(req, resp, fn):
return render_template('/images/{}'.format(fn),
content_type='image/jpeg')

I was wondering if at this point there's just no way to implement it?
Thanks!

@lixas
Copy link

lixas commented Dec 22, 2022

there is function available: server.serve_file() so your code should work this way:

@app.route('/images/<fn>')
def images(req, fn):
    return app.serve_file("/images/{}".format(fn))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants