How to connect to Django from Spring - django

I'm trying to find a way of sending data to my web server on Spring framework from Django which controls actions of tensorflow.
If Spring server send a request, is it possible to send a output from Django?
If you have experiences like this, please give me some tips.

You can simply make an HTTP request to your Django server, respond with JSON, and then parse that JSON into a Java class using a library like jackson.
Alternatively you can use a shared database where Spring simply uses JDBC to access the data you are trying to reach.

Related

How do you create a simple webservice in mule and accept data from a mobile app?

Apologies as I am new to the webservice space. I would like to ask some guidance on how to create a webservice that will receive data from a mobile app (XML or JSON). It will just be a simple call and Inwould need the data to be inserted to our database. I can manage to deal with the DB and the actual flow and my issue is more on how to create the actual webservice from Mule. and thought examples and comment will be appreciated.
Thanks Again
Creating web-services in Mule is pretty easy to implement and start consuming.
You can go through these links to give you a good headstart:
https://docs.mulesoft.com/mule-user-guide/v/3.7/building-web-services-with-cxf
And you can play with this project:
https://github.com/marcotello/MuleESB/tree/master/simplecxfservice
However, as you mention you know something about the mule components and flows, you'll have to do transformation of your XML/JSON input received from the mobile App to be able to be saved in Database properly.
To accept requests from mobile applications - create light weight rest APIs that consume JSON payload over the http protocol.
There are various frameworks to create rest APIs. To develop rest APIs using mule follow:
https://docs.mulesoft.com/mule-user-guide/v/3.7/rest-api-examples
Once you create a rest API, use a JSON-Object transformer with a return type of java.util.map to access each of the fields in the JSON payload.
Check out the available transformers at the below mentioned link.
https://docs.mulesoft.com/mule-user-guide/v/3.7/transformers

Django Post to External Server

I am relatively new to Django/Python. I am currently developing a Django system to track entries to a modelling system our company developed.
Clients should be able to post model run data to a database on our server. The data will be coming from a python script. I was able to make it work on my system using somemodelname.objects.get_or_create, but this will not work externally. I understand I should use a package such as requests and found: How to post a django request to external server. However, this assumes the django code (views, etc) is accessible from the client computer.
How can I make this work so the client data is posted from a python script to the Django database?
Sounds like a good use of a RESTful API. Django Rest Framework and Tastypie are both good packages to use with Django.
Basically, with an API, you can expose your database through urls. You'll have a url like: mysitename.com/api/mymodel that can handle different HTTP methods. If you called that with a POST verb, your view would create a new record for your mymodel model. Thus, when your client computer generates the data in a python script, you would use [requests](http://docs.python-requests.org/en/latest/) to send the data in a POST request to the url endpoint, which would create the record in the database.

emitting Signal from server to the clients in Python Django like SignalR

I'm using Backbone.js and Python Django Combo.
For checking user is authenticated or not, I'm using setTime out method and call a method which make ajax call to the server.
I heard SignalR from my friend who is interested in .Net Technologies. This can emiting signal from server to client. So he say there is no need to poll periodically with signalR.
Any help or idea will be appreciated.
Possible data flow diagram:
.
If you want to control the data that is pushed to your web clients from your Django app, you will need to use SignalR as a relay of sorts which can be hosted with an ASP.NET app.
The ASP.NET app can have REST endpoints accessible only to your Django app, and can then from there based on the REST parameters push messages to some or all of your clients. Example of doing this with ASP.NET MVC.
The SignalR Wiki can be a good resource for this. You will also need to EnableCrossDomain for this setup to work.
If you don't like the idea of setting up another server just to push data to your clients you might prefer a cloud-based offering like Pusher with a prebuilt wrapper around their REST API.
If you want to use Python to actually push to the clients you can use something like tornado.websocket, but that won't support browsers that don't support the final WebSocket spec.

Is sending HTTP POSTs to Django Web API via node.js efficient?

I've built a JSON API in Django. I'd like to send real-time updates from an external service to Django to upsert a model.
I am really looking for insight on the best way to design the system with current/upcoming/active frameworks and tools. My thoughts are using node.js/Django/Foreman described below:
Existing Django JSON API
A node.js app, running via Foreman, that's subscribed to some external channel.
That channel sends node a JSON message
Node consumes message and makes an HTTP POST of JSON to a URL within my Django API.
Django API uses the JSON message to upsert a model within the Django application.
Now, it seems that I should be able to eliminate node.js from this equation, and have a service that lives "a little closer to home", home being the Django app, rather than having to cross HTTP.
Question being: Is the solution I have now an efficient approach, and is there a better way of doing things?
How do you need to subscribe to the other service? If the other service calls one of your Urls directly, just make Django listen there.
If the other service requires your side to act as server (non webserver, eg connects to you on some non web port) you will need to let a server run there, but again I wouldn't use Node but rather write a simple Python server (probably using the asynccore module), which you could start via foreman+manage.py and which would have access to models directly, eg wouldn't need to marshal the data into json just to send it to Django.
If you connect to the other service via a simple tcp connection I still would take the non node approach like described above.
P.S.: Don't bother to much about efficiency -- keep your system as simple as possible before developing over engineered solutions.

Sending data to the web service

I'm developing an application that requires storing data on an internet database.
Because of WP7 doesn't support databases,I think if I send my variables-datas to the web services that i craated,i can do what i want.
I know how to write a webservice but how can i send my variables to the webservice from WP7?
You can have a look at http://www.sterlingdatabase.com/ which provides a nice and lightweight database. I'm also using this in my project and it works fine.