how do I know if a remote user is connected in django?, like gmail chat, or facebook chat... I need that in the templates system. Sorry for my english
If you need just a general idea of who is currently visiting your website, which includes anonymous visitors, use django-tracking app.
If you need a chat application, or need to know exactly who is logged in at any time, this is much more complicated and will require you to know a lot about chat protocols like XMPP and how to use persistent connections with ajax or comet methods. Some starting projects to look at: xmpp-psn and django-xmpp
Also see this web page for a list of non-Django XMPP browser clients: http://xmpp.org/software/clients.shtml
Comet is probably what you want. Look at Orbited, Hurricane or Tornado.
Related
I’ve got a standard client-server set-up with ReScript (ReasonML) on the front-end and a Python server on the back-end.
The user is running a separate process on localhost:2000 that I’m connecting to from the browser (UI). I can send requests to their server and receive responses.
Now I need to issue those requests from my back-end server, but cannot do so directly. I’m assuming I need some way of doing it through the browser, which can talk to localhost on the user’s computer.
What are some conceptual ways to implement this (ideally with GraphQL)? Do I need to have a subscription or web sockets or something else?
Are there any specific libraries you can recommend for this (perhaps as examples from other programming languages)?
I think the easiest solution with GraphQL would be to use Subscriptions indeed, the most common Rescript GraphQL clients already have such a feature, at least ReasonRelay, Reason Apollo Hooks and Reason-URQL have it.
I'm using pyramid to build up a web site and would like to find some modules about sending messages between users accounts in my web site. I've heard that rails has some gems for that such like https://github.com/ging/mailboxer or https://github.com/pluginaweek/has_messages .
I would like to find the python one. Can anyone recommend me some python modules?
Thanks!
You're probably best off using an existing protocol like XMPP. For Plone (a Python CMS) for example there's a complete XMPP integration with collective.xmpp.chat providing multi-user chat and Instant Messaging between authenticated users of a Plone site (demo video).
For Pyramid you'll need to do this integration yourself [1], by running a Jabber / XMPP server (such as ejabberd) and using an existing XMPP client library for Python to communicate with it. There are plenty of XMPP libraries for Python, some of them are described in the answers to this question.
Note: Don't be scared if after looking at XMPP it looks way to complex. XMPP and its extension describe a wide variety of features related to Messaging and Presence, chat is just one of them. If you don't need the other features, simply don't implement them in your webapp.
[1] Actually, there is a Pyramid project that seems to do exactly that: seshat, written by #KirkStrauser. I haven't used it myself, but it looks very promising.
No; direct communication between two individuals isn't possible in web applications because they use stateless protocols; the server does not know if the request is coming from the same person or not.
That being said, what chat applications usually do is store the communications within a database between the 2 individuals, and use AJAX to retrieve them.
There are already lots of chat application tutorials and 3rd party chat application packages online; you might want to check them out.
I'm writing panel for administrating nginx (domains, rewrites, etc), svn and other services. For that, i'm writing backend that will work on root (to change nginx configs, reload them, change user passwords, etc), and client (console client, and web app).
App works on unix sockets, and i made very simple protocol for it:
\0\0\0\0user\0key\0module\0command\0data\0
Well, this is quite simple. Client sends command and data to backend, fox ex:
\0\0\0\0morsik\0\0nginx\0add_domain\0www.domain.tld something\0
Problem is, how to authenticate that user is really morsik? For web interface i don't have to - web page have it's own authorization so i can sent some key that will work for every user that nobody will know.
Problem is if somebody have access to ssh. Then he could write simple client that will spoof username and then he could change other user configuration.
So, how can i made correct authorization for users?
Don't reinvent the wheel. ;) I found this discussion enlightening:
http://cyberelk.net/tim/2007/03/08/cups-unix-domain-sockets-authentication/ Explains the concept of socket auth.
http://pythonic.pocoo.org/2007/7/7/unix-socket-credentials-with-python Helpful details.
http://atlee.ca/software/pam/ This might work also, though less convenient.
Create a group for app admins only, etc.
I want to write a micro blogging site with html frontend but xmpp backend (Instant messenger type). By this, I mean server should push all the updates to client browser and hence constant http polling is not required. I need your view and help in that.
I found 3 xmpp libraries
1. xmppy
2. sleekxmpp
3. pyxmpp
Should i use any of these or should try from scratch. If from these which one will you suggest.
What should i do?
This slideshow may help. The author uses django and some xmpp items that can tag along with django's authentication. This sounds pretty perfect for you.
The link is to google's cache because the original link wouldn't work for me anymore. Let me know if this is a problem.
try this - https://github.com/hj91/Using-XMPP-to-post-content-on-blog-sms-facebook
xmpp to wp blog poster bot code.
it takes incoming xmpp message and posts them on worpdress blogs. written in python and xmpppy library
I've written a Python application that makes web requests using the urllib2 library after which it scrapes the data. I could deploy this as a web application which means all urllib2 requests go through my web-server. This leads to the danger of the server's IP being banned due to the high number of web requests for many users. The other option is to create an desktop application which I don't want to do. Is there any way I could deploy my application so that I can get my web-requests through the client side. One way was to use Jython to create an applet but I've read that Java applets can only make web-requests to the server it is deployed on and the only way to to circumvent this is to create a server side proxy which leads us back to the problem of the server's ip getting banned.
This might sounds sound like and impossible situation and I'll probably end up creating a desktop application but I thought I'd ask if anyone knew of an alternate solution.
Thanks.
You can use a signed Java applet, they can use the Java security mechanism to enable access to any site.
This tutorial explains exactly what you have to do: http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
The same might be possible from a Flash applet. Javascript is also restricted to the published site and doesn't allow being signed or security exceptions like this, AFAIK.
You probably can use AJAX requests made from JavaScript that is a part of client-side.
Use server → client communication to give commands and necessary data to make a request
…and use AJAX communication from client to 3rd party server then.
This depends on the form of "scraping" you intend to do:
You might run into problems running an AJAX call to a third-party site. Please see Screen scraping through AJAX and javascript.
An alternative would be to do it server-side, but to cache the results so that you don't hit the third-party server unnecessarily.
Check out diggstripper on google code.