Closed generalmarty closed 4 years ago
Hi @generalmarty,
What is your platform?
And most importantly, could you send me the result of these 2 stat()
commands from your platform:
import os
os.stat('www/')
os.stat('www/index.html')
Thanks!
Hi @jczic
Platform: pycom wipy 3.0
>>> import uos
>>> uos.stat('/flash/www')
(16384, 0, 0, 0, 0, 0, 0, 28, 28, 28)
>>> uos.stat('/flash/www/index.html')
(32768, 0, 0, 0, 0, 0, 220, 2, 2, 2)
Many thanks.
Ok, I have a WiPy 3R and that's works with the last firmware :o
Did you test by setting the property RootPath
? (may be a problem with current directory on your platform?)
Ex:
mws2.RootPath = '/flash/www'
By default, the root path is set to 'www'
.
Thanks for getting back to me.
Upon double checking, it is only the root path that is not working. All default pages in sub-directories of root (/flash/www
) are working fine.
(html 404) /
-> /flash/www/index.html
(html 200) /index.html
-> /flash/www/index.html
(html 200) /test
-> /flash/www/test/index.html
Directory structure in WiPy:
/flash
/www
index.html
/test
index.html
Hmm.. I'm searching but... I doesn't understand this problem on your WiPy.
Your RootPath is 'www'
(default), '/flash/www'
or '/flash/www/'
?
The function used to find the filepath is mws2.ResolvePhysicalPath(url)
After initialization of mws2, can you print RootPath and call:
mws2.ResolvePhysicalPath('/')
mws2.ResolvePhysicalPath('/index.html')
mws2.ResolvePhysicalPath('/test')
mws2.ResolvePhysicalPath('/test/index.html')
Thank you very much @generalmarty 👍
@jczic
mws2 = MicroWebSrv2()
mws2.RootPath = '/flash/www'
print(mws2.ResolvePhysicalPath('/'))
# >>> None
print(mws2.ResolvePhysicalPath('/index.html'))
# >>> /flash/www//index.html
print(mws2.ResolvePhysicalPath('/test'))
# >>> /flash/www//test/index.html
print(mws2.ResolvePhysicalPath('/test/index.html'))
# >>> /flash/www//test/index.html
P.S.: Same outcomes when mws2.RootPath = '/flash/www/'
Thanks.
Oh it's very strange but there was a bug in ResolvePhysicalPath
on old versions.
So, do you have the last release v2.0.3?
(MicroWebSrv2 print this when it loaded)
@jczic I have tried to format /flash
but the problem still presist.
Using the latest firmware and software.
---------------------------
- Python pkg MicroWebSrv2 -
- version 2.0.3 -
- by JC`zic & HC2 -
---------------------------
Ok, I have exactly the same firmware on a WiPy3 and I don't understand :'(
May be a different rights on files..?
I searched but I've not found anything on my side... If you can help me, all is in the ResolvePhysicalPath()
function.
Hi and thank you! 👍
So, on your platform, the stat
function doesn't works if the path end with '/' !
I've checked your pull request, it's cool but it is just applied if urlPath
equals '/', I've added that for all paths ended with '/'.
(_rootPath
is processed in property set).
Commit : 4e530d7b9c55715d0bbb56fa8959b587f7c8778c
Release 2.0.4 is okay for you?
@jczic v2.0.4 is all good 👍. Thanks.
Top! Thank you again @generalmarty! 👍
Can't get default pages for directory resources to work.
It is ok to directly navigate to
/index.html
. Unfortunately, can't navigate to index.html by simply using/
in the URL.What am I missing? Thanks.