PDA

View Full Version : Accessing server on localhost from opera browser


Andi
2005-12-26, 14:47
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
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
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 (http://pymaemo.sourceforge.net/cgi-bin/moin.cgi/) , 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/showfiles.php?group_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:

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
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
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
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?

Andi
2006-01-18, 14:30
Exactly it ;) How's the server doing?

Sorry for my late answer. I wrote quite a bit code for the python web server on a weekend without having access to a notebook or desktop PC. When I finally tried to backup the code on my notebook via the USB connector, the python file containing my code wasn't readable anymore (I/O Errors).

Right now I'm waiting for my anger to fade away before restarting the project... But I learned my lesson and I won't write or exclusively store a single line of code on the 770.

Andi

fpp
2006-01-18, 17:05
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.

I don't know that I would call a python http server "mini", at least as far as memory footprint and efficiency are concerned. If what you want is a lean and mean server for static content or a couple of cgi's, an ARM binary of boa or tinyhttpd or several others sounds like a better choice.
OTOH, if the goal is to write a local web app in python that is its own web server, using one of the lightweight web frameworks (like Karrigell or Snakelets), that is very convenient. I have one on my Zaurus that I use daily, need to try it out on the 770 someday.

Nyrath
2006-01-18, 17:10
Sorry for my late answer. I wrote quite a bit code for the python web server on a weekend without having access to a notebook or desktop PC. When I finally tried to backup the code on my notebook via the USB connector, the python file containing my code wasn't readable anymore (I/O Errors).
Ooo, I'm sorry to hear that.

Can the code be read with the 770's editor (whatever you used to write the code to start with)? Was the code stored in the 770's RAM or on the RS-MMC card? I'm trying to decide how much to panic about my own 770. I'd hate to think that the onboard RAM is so unreliable.

I suppose you had the USB cable plugged directly into the desktop PC instead of into a USB hub? I had problems flashing the 50 update into my 770 until I did this. And if the code was on the RS-MMC card, have you tried using a desktop PC with a card reader?

Please don't be insulted, I know my suggestions are somewhat obvious, but I don't know how else to help.

mranderso
2006-01-19, 04:12
I copied CGIHTTPServer.py in as well as BaseHTTPServer.py and SimpleHTTPServer.py. Then moved in wypy.py to make a wiki to
record my thoughts. Of course, I'd only have this running on my
home network behind a firewall:)

Frooble
2006-02-08, 00:22
I managed to get MoinMoin v1.3.5 running on my Nokia 770 by adding *Server.py and cgi.py. I have MoinMoin & my wiki on the MMC card and used the installable Python2.4. I had to set full paths in moin.py & wikiconfig.py. I access it via opera using the DEFAULT connection. My only remaining bug is that for some reason [[BR]] is not recognized. All the other formatting commands that I have used seem to work. I will start digging through MoinMoin, but if anyone else has seen this I'd love to know.

ludovic
2007-03-03, 17:51
I'm pretty sure that this is what you're looking for.

http://maemo.org/maemowiki/DummyIAP

Hi,

I try this solution on N800, and it's not OK.

The "dummy" internet access point has been created, and i can connect the tablet, Opera search localhost but don't find.

Have you got an idea ?

Thanks

vvaiman
2007-06-08, 19:54
One more way to get access to your localhost server:

1. tools > conntrol panel > connectivity "connections" button
2 "New" button, "Next button" type in Connection name you desire like "Dummy", option button WLAN, "Next" button.
3. Scan networks "No" button
4. SSID "Dummy", Network mode "Ad hoc", "Next" button, "Advancced" button
5. Checkbox check on Use Proxy, HttP proxy input 127.0.0.1, "OK" button, "Finish" button, "Done" button, "OK" button.

You all set. Now if you want to access your localhost, all you need to do is choose "Dummy" connection from your connections list.

Hope this helps,

Cheers :-)

ifallacy
2007-07-09, 06:24
wow, thanks vvaiman - great solution, just what i was looking for! =]