Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Display local OR remote html page

6 views
Skip to first unread message

Richard Owlett

unread,
Dec 22, 2009, 9:57:32 AM12/22/09
to
I started with the example at "Simple Tkhtml web page displayer"
(http://wiki.tcl.tk/2993).

My initial mods yielded

package require Tkhtml
package require http
pack [scrollbar .vsb -orient vertical -command \
{.html yview}] -side right -fill y
pack [html .html -bg white -yscrollcommand \
{.vsb set}] -fill both -expand 1
set target "http://wiki.tcl.tk/976"
set t [http::geturl $target]
.html parse [http::data $t]
http::cleanup $t

Which worked very nicely.

However when I replaced
set target "http://wiki.tcl.tk/976"
with
set target "file://localhost/c:/ATEST/test.html"
I received
Unsupported URL type "file"

Suggestions/comments?

I'm exploring Tcl and HTML currently.
My learning style is "by experiment" ;)

TIA


George Petasis

unread,
Dec 22, 2009, 3:56:49 PM12/22/09
to Richard Owlett
O/H Richard Owlett έγραψε:
You need to use the uri package from tcllib:

package require uri
package require http

...

set t [uri::geturl $target]
...

George

drsc...@gmail.com

unread,
Dec 22, 2009, 4:09:13 PM12/22/09
to
George Petasis wrote:
> You need to use the uri package from tcllib:
>
> package require uri
> package require http
>
> ...
>
> set t [uri::geturl $target]
> ...
>

What is the difference between http::geturl and uri::geturl? Recently
there was a discussion on http's geturl which resulted in some
improvements, I believe. Would uri's version have the same features?


DrS


Gerald W. Lester

unread,
Dec 22, 2009, 5:55:38 PM12/22/09
to

Look at the code for URI and see if you can answer the question.


--
+------------------------------------------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

drsc...@gmail.com

unread,
Dec 22, 2009, 6:04:59 PM12/22/09
to
Gerald W. Lester wrote:
>
> Look at the code for URI and see if you can answer the question.
>
>


Let's not and say I did.


DrS

Tcl Bliss

unread,
Dec 22, 2009, 7:24:16 PM12/22/09
to

Why are you trying to access a local file via http?
Just do:

set file [open c:/ATEST/test.html]
.html parse [read $file]
close $file

Richard Owlett

unread,
Dec 22, 2009, 7:56:22 PM12/22/09
to

I wasn't aware of the uri package. Thank you.
But it doesn't work :(


Administrator) 1 %
(Administrator) 1 % package require uri
1.2.1
(Administrator) 2 % set target "file://localhost/c:/ATEST/test.html"
file://localhost/c:/ATEST/test.html
(Administrator) 3 % set t [uri::geturl $target]
couldn't open "/c:/ATEST/test.html": no such file or directory
(Administrator) 4 %
(Administrator) 4 % # *################################*
(Administrator) 5 % glob c:/ATEST/test.html
c:/ATEST/test.html
(Administrator) 6 %

Also
'uri(n) 1.2.1 "Tcl Uniform Resource Identifier Management" '
does not seem to show something similar to http::data .


Richard Owlett

unread,
Dec 22, 2009, 9:03:20 PM12/22/09
to


'Cause 'My learning style is "by experiment" ;)'

Actually there is a little more too it.

When in unfamiliar territory I do a lot by inference. Most
browsers don't seem to make a major distinction between pages
retrieved from a remote system retrieved over the web and those
from a local drive.

As part of my HTML learning experience I'm trying to reproduce
the functional result of a web page whose HTML is just plain
ugly. So I'll be switching back and forth between my attempt and
what is on the web.

> Just do:
>
> set file [open c:/ATEST/test.html]
> .html parse [read $file]
> close $file
>

I did do that to verify the integrity of my local file. But I
wanted to find out why my original attempt failed. My formal
computer training ended about the time 1200 BAUD was very fast
and ARPANET was being proposed. I'm retired so I can did into
what catches my attention.

Thanks for the feedback.

Fredderic

unread,
Dec 22, 2009, 11:57:05 PM12/22/09
to
On Tue, 22 Dec 2009 18:56:22 -0600,
Richard Owlett <row...@pcnetinc.com> wrote:

> George Petasis wrote:
> > You need to use the uri package from tcllib:
> > package require uri
> > package require http

> > set t [uri::geturl $target]

> I wasn't aware of the uri package. Thank you.
> But it doesn't work :(
>

> (Administrator) 2 % set target "file://localhost/c:/ATEST/test.html"
> file://localhost/c:/ATEST/test.html
> (Administrator) 3 % set t [uri::geturl $target]
> couldn't open "/c:/ATEST/test.html": no such file or directory
> (Administrator) 4 %

Does ANYTHING handle that URL reliably...? What's the default network
protocol to reach C: on localhost? SMB? NTFS? FTP? HTTP? BT? or
any of a whole host of other file transfer protocols. Last I heard,
"file:" means don't touch the network, go direct to local storage, so
having a host to retrieve the file from sounds a little odd.

Just "file:///c:/ATEST/test.html" aught to work... Perhaps the URL
parsing could drop localhost if it sees it as the host, but then it'd
also have to check for the local hostname, at least two IP addresses,
etc.


Fredderic

Arnold Snarb

unread,
Dec 23, 2009, 12:12:44 AM12/23/09
to

Great, OK! "You looked at the code".

Let's also say you know the answer now.

Or we could also say you looked at TFM, and
you should also know the answer now.


--AS

Tcl Bliss

unread,
Dec 23, 2009, 1:08:52 AM12/23/09
to

Because the HTTP package was designed to deal with web servers, not
local files. There is no need to use HTTP package with local files.
Web browser can tell the difference between a web server and a file
system. They need to, because they have to try to display that file.
HTTP package just connects to the web server and reads the page from
it and does what is was designed to do, which is to return the html
code to you. It was not designed to display it, or read just any kind
of file.

drsc...@gmail.com

unread,
Dec 23, 2009, 3:50:51 AM12/23/09
to
Arnold Snarb wrote:
>
> Great, OK! "You looked at the code".
>
> Let's also say you know the answer now.
>
> Or we could also say you looked at TFM, and
> you should also know the answer now.


I am not the OP, and I am not looking for an answer. So, follow your
own suggestion and go look at TFA yourself.


What is with the idiotic reply? Neither yours nor Gerald's post helps
anyone or contributes anything to the discussion. As the OP noted, the
uri package did not help, and others were not aware of the package.

DrS

Donald Arseneau

unread,
Dec 23, 2009, 4:02:48 AM12/23/09
to
On Dec 22, 8:57 pm, Fredderic <fredde...@gmail.invalid> wrote:
> > file://localhost/c:/ATEST/test.html

> Does ANYTHING handle that URL reliably...?

> "file:" means don't touch the network, go direct to local
> storage, so having a host to retrieve the file from sounds
> a little odd.

You are right. I don't believe there is a file
"/localhost/c:/ATEST/test.html", so the attempt
*should* result in an error.

Donald Arseneau

Richard Owlett

unread,
Dec 23, 2009, 9:54:14 AM12/23/09
to


This is becoming a fascinating study of "how much that I 'know'
just ain't so" and the role of unstated/unrecognized assumptions
warp what you see.

For any fellow newbies following newbies, here are some links
with food for thought:

http://en.wikipedia.org/wiki/Uniform_Resource_Locator
http://en.wikipedia.org/wiki/URI
http://en.wikipedia.org/wiki/Uniform_Resource_Name
http://en.wikipedia.org/wiki/Http
http://en.wikipedia.org/wiki/List_of_file_transfer_protocols


tom.rmadilo

unread,
Dec 23, 2009, 11:20:33 AM12/23/09
to
On Dec 22, 10:08 pm, Tcl Bliss <tcl.bl...@gmail.com> wrote:
> Because the HTTP package was designed to deal with web servers, not
> local files. There is no need to use HTTP package with local files.
> Web browser can tell the difference between a web server and a file
> system. They need to, because they have to try to display that file.
> HTTP package just connects to the web server and reads the page from
> it and does what is was designed to do, which is to return the html
> code to you. It was not designed to display it, or read just any kind
> of file.

While looking at the code for the ::http package, I seem to remember
that you can add protocol handlers. "file" is a protocol. I have no
idea why the http package was designed to handle non-http protocols,
but someone could add "file" if needed.

Donal K. Fellows

unread,
Dec 23, 2009, 12:22:50 PM12/23/09
to
On 23 Dec, 16:20, "tom.rmadilo" <tom.rmad...@gmail.com> wrote:
> While looking at the code for the http package, I seem to remember
> that you can add protocol handlers. "file" is a protocol. I have no
> idea why the http package was designed to handle non-http protocols,
> but someone could add "file" if needed.

The key requirement was the "https" protocol, which needs an external
library (tls package) to handle the crypto. (Well, maybe you could do
it in Tcl nowadays. Quite a bit of work though.) I suspect that it's
going to be difficult to handle the file protocol in less than 8.6
because the http package assumes that it can talk the HTTP protocol
over the channel established by the basic protocol handler; the http
package isn't a general URL system.

Donal.

Andreas Kupries

unread,
Jan 16, 2010, 12:29:50 PM1/16/10
to
drsc...@gmail.com writes:

Documentation at
http://docs.activestate.com/activetcl/8.5/tcllib/uri/uri.html#5

I.e. uri::geturl handles file urls itself, and for other schemata,
like http, ftp, etc. it calls on the http::geturl / ftp::geturl
etc. commands, in the packages http, ftp::geturl, etc.

--
So long,
Andreas Kupries <akup...@shaw.ca>
<http://www.purl.org/NET/akupries/>
Developer @ <http://www.activestate.com/>
-------------------------------------------------------------------------------

0 new messages