![]() |
Forum Index : Microcontroller and PC projects : PicomiteWEB Web File Manger
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
![]() Two files are required. Both included in the zip Tested on alpha12 ie before telnet. I will try it on the later alphas when time permits. Still a lot to do and the CHDIR field does nothing for now. This is a fast way to get data files and bas files etc off the pico. No way to get files onto the pico... web_fm.zip Jim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Well, it ran happily all night (on a12) so it is time to add more functions and try a16. This current version is available at http://tassyjim.ddns.net:50080/fm.html I intend to add buttons for changing drive and similar but not for the public available server. Imagine what fun someone could have with a delete button! Jim VK7JH MMedit |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
Jim: For me, the link was missing the ":" after "http" (which is there in the text). PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Thanks http://tassyjim.ddns.net:50080/fm.html I also changed things so you don't need the /fm.html, it now defaults to that instead of index.html. http://tassyjim.ddns.net:50080 Jim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
The last user managed 16 pages before: (there are a lot of the MMEdit help files missing form this system which explains the 404 errors. [08:43:40] mmcc_edit.htm [08:43:40] 16 08:43:39 mmcc_edit.htm [08:43:40] 404 mmcc_edit.htm [08:43:40] status = *--- [08:43:41] Error: Invalid address - resetting It wouldn't be so bad if it didn't also erase the program. Jim Edited 2023-02-16 07:54 by TassyJim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
The server keeps crashing with Error : No free connections No problems here locally. One possible reason is the callers browser is trying for re-sends without waiting for the server to reconstruct the web page. It takes a while to read the directory, sort it and do the substitution in the page before sending. I will set up a test facility to look further. Gardening duties now call so it will be later. Jim VK7JH MMedit |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
It could be network latency, or too-many-browsers error. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Network latency is the main cause. I can simulate that by putting a 300mS pause in the code and I then get the errors locally. I have reduced the number of files displayed (= number of variables used) and stopped sorting the list. I will do some proper timing tests later... Jim VK7JH MMedit |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
Okay, Jim. Change your fm.html to <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="GENERATOR" content="TheMonkeys"> <style type="text/css"> a{{width:30vh;display:inline-grid;} </style> <title>Web File Manager</title> </head> <body> <h1 align="center">Web File Manager</h1> <form name='f1' method='get' action='fm.html'> <input type='text' name='T1' size='20'><input type='submit' value='CHDIR' name='B1'> </form> {showlist$()} </body> </html> make the following changes to fm_server.bas inc n filename$(n) = "" (break tag - it gets hidden by the browser) between the dirs and files in makelist then add Function showlist$() Local n = 1 showlist$ = "" Do While filename$(n) <> "" showlist$ = showlist$ + filename$(n) + Chr$(13) + Chr$(10) Inc n Loop End Function This works for me. The more HTML in the file, the longer that the server takes to sift through it looking for "{something}". Plus, you dont have to make room for 70 entries ![]() Oh, and lose the sort. "Files" does it already, methinks. Chris. Edited 2023-02-16 14:43 by TheMonkeys |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I like your thinking Chris but maximum string length is 255 bytes so you will have grief with more than 10 or so files. I am not sure if we can do it with a longstring. Normal sorting of file list is ASCII so files starting with uppercase mess up the listing. I used sort to allow a case agnostic sort. The time taken to create the list and sort it is about 24mS so not an issue. Doing the substitution on the fly doesn't seem to make any difference to the time taken to return the first packet of a page. about 330mS by my count. A page with no variables takes the same time. Interestingly, the time is ~330mS at 250MHz and 260mS when running at 133MHz. The big PAUSE I tried in the sub did show up but I was still able to use it locally. I think there is an inherent delay with the pico which is likely to restrict it to local low latency networks. Not really a problem but interesting. Jim VK7JH MMedit |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
Oops. I hadn't thought of that. As for the page itself, there will be a delay while it parses the HTML, as it searches for "{"s. That Instr search I mentioned earlier ("piml html ico jpg bmp ") does run faster than having a select/case for each filetype when doing the WEB Transmit. ("piml" is my name for a pico "script". that way raw HTML pages can be spat straight through). Chris. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Any HTML page will get searched, having variables embedded or not. A flag to indicate "don't search" would be handy, for speed and for those occasions when there are { characters in the file. I kept the select case just in case I want to treat each type differently. I have now updated to a16 so 8 connections which might help. Jim VK7JH MMedit |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
That's the difference. "piml" files are Web Transmit Page. HTML, like all other file types are Web Transmit File. Put the "Page" files at the start of the list. Then the Instr can be used to decide whether "File" or "Page" is selected. My reasoning is that one Instr is faster that a series of Cases. Good point, I'm still running a11. Time to fix that. Chris |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
Hi Jim, Here's the working code for subdirectories: the page: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="GENERATOR" content="TheMonkeys"> <!--link href="dom/core_c.css" type="text/css" rel="stylesheet"--> <style type="text/css"> a{{width:18vw;display:inline-grid;} </style> <title>Web File Manager</title> </head> <body> <h1 align="center">Web File Manager</h1>
</body> </html> Add this to the declarations: Dim sdir$="" ' subdir Add this to the top of gotrequest (just the "NEW" stuff - indented code shown for reference) Local arg$(1,maxargs-1) sdir$="" ' NEW For a%=1 To MM.Info(max connections) and here's the updated makelist: Sub makelist Local f$, n, k For n = 1 To 72 filename$(n) = "" ' clear old entries Next n = 0 f$ = Dir$(sdir$+"*",DIR) If sdir$ <> "" Then Inc n: filename$(n) = ".. ' : Print /+sdir$ Do While f$ <] If Right$(f$,1) <]"." Then ' skip the ./.. Inc n filename$(n) ="<a href='fm.piml?dir="+f$+"'>"+f$+"/" 'Print "_"+f$ EndIf f$ = Dir$() Loop Inc n filename$(n)=" " f$ = Dir$(sdir$+"*",FILE) Do While f$ <> "" Inc n filename$(n) ="<a href="+Chr$(34)+f$+Chr$(34)+">"+f$+"" 'Print "-"+ f$ f$ = Dir$() Loop End Sub Oops, missed the argument bit ' process arguments before returning page with updated results If page$ = "fm.piml" Or page$ = "fm" Then For i=0 To nparams% If arg$(1,i) <> "" Then Print arg$(0,i);"=";arg$(1,i) If arg$(0,i) = "dir" Then sdir$=arg$(1,i)+"/" ' NEW Next i makelist Edited 2023-02-17 12:36 by TheMonkeys |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
The Do While f$<]" should be: Do While f$ <> "" and the If Right$(f$,1) <]"." Then should be: If Right$(f$,1) <> "." Then and the filename$(n)=" " is supposed to be adding a "<"BR">" tag. (escaped so that it doesn't get hidden). |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
Thanks for the contributions. I am not going to do too much to the html until I finish debugging with Peter. Too many changes make it harder to compare results. Jim VK7JH MMedit |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
Hi Jim, No worries. I created a sub directory "dom" and put "core_c.css" in it. The code navigates into - and out of - the sub directory, shows the files, and as you can see in the commented line in my html, the browser successfully loads the file from there. I'll leave it at that for now. Cheers, Chris. |
||||
TheMonkeys![]() Regular Member ![]() Joined: 15/12/2022 Location: AustraliaPosts: 59 |
Oh, yes. That line: If sdir$ <> "" Then Inc n: filename$(n) = ".. ' : Print /+sdir$ Should read: If sdir$ <> "" Then Inc n: filename$(n) = "_a href='fm.piml'_.._a_" Add the tag bits instead of the underscores. |
||||
Michal Senior Member ![]() Joined: 02/02/2022 Location: PolandPosts: 125 |
Hi Jim Can you post the current complete application sources? Michal |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
The files are getting changed daily as I learn how for I can push things. I will post an update in a few days when things settle down. If you want to experiment, the initial files are a good starting point. Jim VK7JH MMedit |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |