I wrote an app with Android Studio and want to send the data that the user enters to my back-end Python script. This should constantly process the received data and send back the evaluation.
Does anyone have an idea how this could work?
thanks in advance
WebSocket should be the interface of choice.
The python script should expose a WebSocket end point . The mobile app can establish a connection to the WebSocket. The socket can act as a bidirectional channel where the app can send and receive data and the python script can do the same.
Firebase : The app could publish the user inputs to a Firebase topic which the python script listens to. The script can process the inputs and publish to the same channel that the app would listen to. More like a P2P chat
From Backend Python: Create 2 web services (GET or POST depending on the requirements). One is to receive the data from Mobile app and other is to send the data to mobile app.
From Android App: You can use Retrofit or volley library for networking and then consume these web services. Use the web service and send the data(Payload) to the backend and also you can use polling to get the data back to the app.
Related
Currently I am working on a Schoolproject and I need to send a Notification to a self written Xamarin Forms App from my API. It all runs on a local network and the App can already communicate with the Api, now i want my api to send a notification to my phone if a specific event turns true. How do I do this? (Oh and I am using Python flask for my API, if u need this Information)
Use Push notification for it. As soon as there is a need to call
mobile app from web server send a push notification. Handle the push
notification on application side to make a call to web api as soon as
it receives the push notification with specific payload.
Use Web Sockets if server events are too frequent.
I have an Android app to which I send push notifications via firebase. Now I am making a Django app that will run on my server. I wanted to send the notification to my app using that django app. I started testing the firebase admin SDK for python. I was learning from here. I implemented the example code given by the documentation which you can see here and it works on the test android app. The problem is that I need the registration tokens of the devices to send a notification which I have not collected. Or I can send a notification to a topic but the problem is that the app users have not subscribed to topics. I previously used firebase console to send the notifications. I used this option while sending notifications:
Using this option, I sent the notification to all the users of my app. How can I do this with the admin sdk? I want to send notification to all the users of the app. I also tried py-fcm to do this but could not find success. It has the same problem. (If the problem can not be solved using the admin sdk, tell some other library or method to use)
you can not send to all devices in your Firebase panel.
you should use "Topic" or "Group" for sending to multiple devices.
You can use the "not" operation by excluding a non-existing topic.
!('TopicA' in topics)
With this expression, any app instances that are not subscribed to TopicA, including app instances that are not subscribed to any topic, receive the message. If you make sure that none of your users subscribe to "TopicA", you are essentially sending the message to all of your users.
Hi all thanks for help (in advance)
I developed an HTML form, which takes source and destination from the user and uses python in background to combine those files. I hosted this in my web server but if a user is entering the path which is in his desktop my application is not reading. It is searching for the path in the webserver but not in the user desktop.
You need to provide a way for the client to send the file to the server. The app is running on your web server which has its own file system. This server will not have direct access to clients' file system (this would be a huge security concern).
Sounds like you are trying to develop this as if it is a local app on the client's machine. This is not the case because you deployed part of the app to your web server. Think of your app as two pieces. Server side application / client side application. You need to create a way for these two to communicate with each other in a secure manner.
What you are looking for can be done with a REST endpoint on the server side where a client can send the file to the server via a POST request.
Basically the client side of the app (your webpage) could prompt the client to select a file on their machine and then send the contents of the file(s) via HTTP POST to the server side of your app where your python code performs whatever operations you want. The server app could even send a response back to client (the combined files maybe).
Something like this is what you ultimately need to do... note that in this link they developed BOTH server/client parts of their app in python. In your case you have created a webpage client frontend that will run in a browser. You would need to add some code to your webpage to have the user upload a file from their machine and send it to the server.
Sending files between client - server through TCP socket in python?
I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App.
I don't know how to proceed to link the WebJob to the web app.
Any ideas ?
You have two main options:
You can have the WebJobs write the values to a database or to Azure Storage (e.g. a queue), and have the Web App read them from there.
Or if the WebJob and App are in the same Web App, you can use the file system. e.g. have the WebJob write things into %home%\data\SomeFolderYouChoose, and have the Web App read from the same place.
You would need to provide some more information about what kind of interface your web app exposes. Does it only handle normal HTTP1 requests or does it have a web socket or HTTP2 type interface? If it has only HTTP1 requests that it can handle then you just need to make multiple requests or try and do long polling. Otherwise you need to connect with a web socket and stream the data over a normal socket connection.
I have a Python/Flask backend and an Angular frontend for my website. At the backend there is a process that occasionally checks SQS for messages and I want it to push a notification to the client which can then in turn update an Angular controller. What is the best way to do this my existing technologies?
To be able to push to the client, you'll have to implement web socket support in some fashion. If you want to keep it in python/flask, there is this tutorial on how to do that with gevent:
http://www.socketubs.org/2012/10/28/Websocket_with_flask_and_gevent.html
In that article, Geoffrey also mentions a SocketIO compatible library for python/gevent that may allow you to leverage the SocketIO client-side JS library, called "gevent-socketio".
That may reduce how much work you have to do in terms of cross-browser compatibility since SocketIO has done a lot of that already.
Here is a pretty good tutorial on how to use SocketIO in AngularJS so that you can notify the AngularJS model when an event comes in from SocketIO:
http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/
If you don't want to host the web socket backend, you could look to a hosted service like PubNub or Pusher and then integrate them into AngularJS as a service. You can communicate with these services through your Python app (when the SQS notification happens) and they'll notify all connected clients for you.
I know this is a bit late, but I have done pretty much exactly what you ask for (though without Angular).
I ended up having a separate process running a websocket server called Autobahn, which listens to a redis pub/sub socket, the code is here on github
This allows you to send push notifications to your clients from pretty much anything that can access redis.
So when I want to publish a message to all my connected clients I just use redis like this:
r = redis.Redis()
r.publish('broadcasts', "SOME MESSAGE")
This has worked fairly good so far. What I can't currently do is send a push notification to a specific client. But if you have a authentication system or something to identify a specific user you could tie that to the open websockets and then be able to send messages directly to a specific client :-)
You could of course use any websocket server or client (like socket.io or sock.js), but this has worked great for me :-)