My picture isnt showing, I tryed copying code and that didnt work. I want to be able to do this, what am i doing wrong?
my code
from bottle import route, run,Response,template
from bottle import *
import socket
temp=open("ht","r")
html1=temp.read()
temp=open("html2","r")
html2=temp.read()
@route("/")
def route1():
return html1
run(host=socket.gethostbyname(socket.gethostname()), port=8080, debug=True)
in html1
<img src="C:\Users\radbo\Desktop\discord bots\drago\chat\RUn\Servers\Turtle.png" width=290 length=100>
Use the template
function to call your HTML so it is cached, then create a static path to your image file.
from bottle import route, run, response, request, template, static_file, get
@route("/")
def route1():
#this should be your full filename, like index.html
return template('ht')
@get('/static/<filepath:path>')
def _shared(filepath):
return static_file(filepath, 'C:\Users\radbo\Desktop\discord bots\drago\chat\RUn\Servers' )
run(host='127.0.0.1', port=8080, debug=True)
Then you can just do:
<img src="\static\Turtle.png" width=290 length=100>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.