Maybe give a try to libsoup? It seems to have an async API so it should work without threads... There is a vala example here<div><br></div><div><a href="https://wiki.gnome.org/Vala/LibSoupSample">https://wiki.gnome.org/Vala/LibSoupSample</a><br>
<div><br></div><div><br><br>On Tuesday, 24 September 2013, Gonzalo Odiard wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks James.<div><br>
</div><div>In other news, I have tried add a simple web server,</div><div>but apparently I couldn't make run webkit and the webserver together,</div><div>even using threads.</div><div>
<br></div><div>Gonzalo</div></div><div><br><br><div>On Thu, Sep 19, 2013 at 7:46 PM, James Cameron <span dir="ltr"><<a>quozl@laptop.org</a>></span> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I just love sockets.<br>
<br>
But that seems wrong to me; to open a socket to get a port number and<br>
then shut it down. Presumably later code would open another socket<br>
and bind it to the port?<br>
<br>
If you truly need to do it that way, there's one more thing to add<br>
before the call to bind():<br>
<br>
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)<br>
<br>
This is so that the same port number can be re-used shortly<br>
afterwards. Otherwise the later code would see an address in use<br>
error.<br>
<div><div><br>
On Thu, Sep 19, 2013 at 08:56:31AM -0300, Gonzalo Odiard wrote:<br>
> A free port can be get using:<br>
><br>
> # Get a free socket<br>
> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)<br>
> sock.bind(('', 0))<br>
> sock.listen(socket.SOMAXCONN)<br>
> _ipaddr, self.port = sock.getsockname()<br>
> sock.shutdown(socket.SHUT_RDWR)<br>
> logging.error('Using port %d', self.port)<br>
><br>
> Should be good use 0.0.0.0 as ip instead of localhost, to avoid [1]<br>
> To serve the files python already have HTTPServer.<br>
><br>
> Gonzalo<br>
><br>
> [1] <a href="http://dev.laptop.org/ticket/12479" target="_blank">http://dev.laptop.org/ticket/12479</a> <br>
><br>
><br>
> On Wed, Sep 18, 2013 at 9:39 PM, Daniel Narvaez <<a>dwnarvaez@gmail.com</a>> wrote:<br>
><br>
> Just a directory. It needs to be one server per activity though, so that<br>
> the different port gives us a different origin.<br>
><br>
><br>
> On 18 September 2013 23:32, Gonzalo Odiard <<a>gonzalo@laptop.org</a>> wrote:<br>
><br>
> Ok. Thanks.<br>
> The web server need have something special or just serve a directory is<br>
> enough? <br>
><br>
> Gonzalo<br>
><br>
><br>
> On Wed, Sep 18, 2013 at 6:22 PM, Daniel Narvaez <<a>dwnarvaez@gmail.com</a>><br>
> wrote:<br>
><br>
> Well, there are several html features which depend on each activity<br>
> having their own origin, for example local storage.<br>
><br>
><br>
> On Wednesday, 18 September 2013, Gonzalo Odiard wrote:<br>
><br>
> No, why is needed use a local web server instead of<br>
> the use of the proposed solution (use '<br>
> enable-file-access-from-file-uris' )<br>
><br>
> Gonzalo<br>
><br>
><br>
> On Wed, Sep 18, 2013 at 6:06 PM, Daniel Narvaez <<br>
> <a>dwnarvaez@gmail.com</a>> wrote:<br>
><br>
> You mean why the http server would be a problem?<br>
><br>
><br>
> On Wednesday, 18 September 2013, Gonzalo Odiard wrote:<br>
><br>
> This is for the potential security risk of opening<br>
> files outside of the activity directory,<br>
> or because can be a problem with different activities<br>
> running at the same time<br>
> or multiple instances of the same activity?<br>
><br>
> Gonzalo<br>
><br>
><br>
> On Wed, Sep 18, 2013 at 5:46 PM, Daniel Narvaez <<br>
> <a>dwnarvaez@gmail.com</a>> wrote:<br>
><br>
> You could put an http server in the activity...<br>
> Sucks but I'm not sure there is a better way :/<br>
><br>
><br>
> On Wednesday, 18 September 2013, Manuel Quiñones<br>
> wrote:<br>
><br>
> I finally got web activities working on XO-4,<br>
> in the AU build<br>
> published yesterday [1] . I did it by<br>
> modifying webactivities.py to<br>
> use WebKitGTK1 instead of v2. The changes</div></div></blockquote></div></div></blockquote></div></div><br><br>-- <br>Daniel Narvaez<br><br>