i've got some issues serving files on my web.py application : Python 3.7 web.py ver0.40_Dev1 Eclipse Photon Release (4.8.0)
app.py :
import web
render = web.template.render('templates/')
urls = (
'/', 'index',)
class index:
def GET(self):
return render.index()
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
templates/index.html :
<html>
<h2>HELLO</h2> <img src = "/static/image.png">
</html>
I manually created /templates and /static folders And I get the following error when displaying my index on localhost :
> AttributeError("'StaticApp' object has no attribute 'directory'")
> Traceback (most recent call last): File
> "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/web/wsgiserver/wsgiserver3.py",
> line 1089, in communicate
> req.respond() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/web/wsgiserver/wsgiserver3.py",
> line 877, in respond
> self.server.gateway(self).respond() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/web/wsgiserver/wsgiserver3.py",
> line 1982, in respond
> for chunk in response: File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/web/httpserver.py",
> line 255, in __iter__
> path = self.translate_path(self.path) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/server.py",
> line 820, in translate_path
> path = self.directory AttributeError: 'StaticApp' object has no attribute 'directory'
Trying : (with image at the root)
<img src = "/image.png">
returns casual 404 error (files are supposed to be served from /static right?)
And reaching : localhost/static
returns "not found"
http://webpy.org/cookbook/staticfiles seems to tell me files serving from /static file is automatically handled by web.py ? (or i don't get it)
Anyway : i can't serve any file in my app.py...
any help ?