I have set up a bottle server and I want to launch both index.html and second.html pages which are located in my main website folder. The code I've previously used to display index.html is:
@route('/')
def server_static(filename="index.html"):
return static_file(filename, root='./index.html')
At the moment, it won't work and it will throw a server error saying that the file does not exist. How can I launch not only my index, but my other pages as well?
root
needs to be the path to the folder containing your files, not the file itself:
@route('/<filename>')
def server_static(filename):
return static_file(filename, root='/path/to/files')
So requesting example.com/index.html
will serve the file at /path/to/files/index.html
.
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.