maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Accessing server on localhost from opera browser (https://talk.maemo.org/showthread.php?t=842)

Andi 2005-12-26 14:47

Accessing server on localhost from opera browser
 
Hi!

I wrote a simple HTTP server for my Nokia 770 using python for maemo. While the server itself works perfectly I have troubles accessing it from the opera browser without establishing an internet connection. Even when in offline mode opera insists on connecting when I try to access a local server. The loopback device is up and there is no problem connecting to my server using the GPE-mini-browser.
Any ideas how to change this behaviour?

Thank you, Andi

bigboote 2005-12-26 20:22

Quote:

Originally Posted by Andi
Hi!

I wrote a simple HTTP server for my Nokia 770 using python for maemo. While the server itself works perfectly I have troubles accessing it from the opera browser without establishing an internet connection. Even when in offline mode opera insists on connecting when I try to access a local server. The loopback device is up and there is no problem connecting to my server using the GPE-mini-browser.
Any ideas how to change this behaviour?

Thank you, Andi

Andi,

I'm glad to hear you're working on this, and I hope your problem can be resolved. Having a mini httpserver on board could be a powerful tool.

Would you be so kind as to describe exactly (as in, instructions for Linux newbies) how you installed Python on your 770?

John

Hedgecore 2005-12-26 20:29

Andi: The only thing to override that behaviour that i can think of is a patch of sorts. While the lloopback IP exists, can you setup an ad-hoc connection that doles out an IP on the
local range to the 770? Or would it be possible to create a connection that would use the loopback? (Not sure about that last one as 127.0.0.1 would lready be assigned to the device).

Other than that, maybe Opera can be set to offline mode.

Andi 2005-12-27 11:08

Quote:

Originally Posted by bigboote
Andi,

I'm glad to hear you're working on this, and I hope your problem can be resolved. Having a mini httpserver on board could be a powerful tool.

Would you be so kind as to describe exactly (as in, instructions for Linux newbies) how you installed Python on your 770?

John

John,

Installing Python for Maemo is quite easy, there is a description on the Python for Maemo Page , but I'll summarize the steps for you:

1. Install the terminal emulation from http://770.fs-security.com/xterm/ on your 770 using the application installer.

2. Download the python packages from http://sourceforge.net/project/showf...roup_id=144664 , I'd recommend getting at least python2.4_2.4.1-2indt7_arm.deb and python2.4-modules_2.4.1-2indt7_all.deb if you want to do some serious programming.

3. Fire up your xterm and get root by typing "sudo /usr/sbin/gainroot"

4. Install the python packages by typing "dpkg -x python2.4-XXX_arm.deb /"

5. The python2.4-modules package doesn't contain the complete python standard library. To get full pythonic convenience when writing my little webserver, I copied the files cgi.py, BaseHTTPServer.py and SimpleHTTPServer.py from my desktop python installation (living in /usr/lib/python2.4/) to the same directory on my 770.

6. Have fun writing python code. A simple example for a python web server is:
Code:

from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
host, port= '', 50000
print 'listening on port', port
srvr= HTTPServer((host, port), SimpleHTTPRequestHandler)
srvr.serve_forever()

Save this piece of code in a file called "srvr.py" and start it up by typing "python2.4 srvr.py". It will serve any files in its current directory.

Happy Hacking, Andi

Andi 2005-12-27 11:49

Quote:

Originally Posted by Hedgecore
Andi: The only thing to override that behaviour that i can think of is a patch of sorts. While the lloopback IP exists, can you setup an ad-hoc connection that doles out an IP on the
local range to the 770? Or would it be possible to create a connection that would use the loopback? (Not sure about that last one as 127.0.0.1 would lready be assigned to the device).

Other than that, maybe Opera can be set to offline mode.

Hi!

I'm not sure whether I got your point. I'd consider it best if there was a possibility to tell opera not to try to establish an internet connection when the server is local. Since there is no such behaviour with the GPE browser, I conclude that the connection process is triggered by opera, not by the operating system. You're right, an "offline mode" for opera would be nice.

Your idea of creating some kind of "fake connection" is very interesting. I'll look around a bit in order to find out whether there is a practical way to create such a beast.

Thanks, Andi

Hedgecore 2005-12-27 15:00

Andi: What I'd meant was if it wants a connection, give it one; much in the same way you can take a standalone PC and give it a static IP, you could (/should be able to) do the same with the 770. If Opera tries hitting your local webserver and sees the 770 has an IP of 192.168.0.1, that might make it happy.

Obviously that'd only be a bandaid solution, having zero internet connectivity while using a local web server would be a pain in some instances.

I haven't tried it, but creating an ad-hoc connection with a static IP in connection manager oughtta do it.

gultig 2005-12-27 17:09

I'm pretty sure that this is what you're looking for.

http://maemo.org/maemowiki/DummyIAP

Andi 2005-12-27 21:26

Quote:

Originally Posted by gultig
I'm pretty sure that this is what you're looking for.

http://maemo.org/maemowiki/DummyIAP

That's it. Thank you very much.

Andi

Andi 2005-12-27 22:20

Quote:

Originally Posted by Hedgecore
I haven't tried it, but creating an ad-hoc connection with a static IP in connection manager oughtta do it.

Gultigs hint solved my problem (solution: http://maemo.org/maemowiki/DummyIAP) but lacking GNOME knowledge I don't know nothing about the deep magic of the gconftool command. Maybe it has the power to add a static local IP address to the connection manager (I think that's your idea, isn't it?).

Thank you and happy hacking, Andi

Hedgecore 2006-01-03 03:40

Exactly it ;) How's the server doing?


All times are GMT. The time now is 09:39.

vBulletin® Version 3.8.8