Sorry in advice for my strange english.
I have to develop a client application with python that comunicate with a php server that uses JSON protocol for data exchange.
There are many python frameworks that permit to implement MVC pattern, and in particular with structured Models for data handling, but all these model structures talk directly with a database in SQL language.
My purpose is to use a single server that shots data with JSON api to all kind of devices or platforms.
So, in my python application, i would to write a syncing model storage that talks directly with my Json Server as well as an ExtJs 4 app, using a framework or a library that permits to implement easily my request.
Does anybody knows any tools that permits this ?
If I understood your question correctly, you're looking for a proxying solution to put between application server clients. It may not be 100% fit but I'd suggest looking at Ext.Direct remoting that's built in Ext JS; RPC should work fine if you don't have to publish and maintain your API. As for proxying, take a look at RPC::ExtDirect::Client. It's an Ext.Direct client implementation in Perl; I developed it mostly for testing purposes but it can probably be used for proxying, too.
On a side note, I'm not sure why exactly you would want to implement such an architecture at all. It sounds overcomplicated for no good purpose.
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 built a machine learning model of binary classification in python.
It works on my laptop (e.g. command line tool). Now I want to deploy it in production on a separate server in my company. It has to take inputs from another server (C# application), make some calculations and return outputs back to it.
My question is what are the best practices of doing such thing in production? As I know it can be done through TCP/IP connection.
I am new in this field and I don't know the terms used here.
So can anybody guide me?
Thanks.
I would say it depends on your infrastructure and how can the other application (C#) can communicate.
The easiest way in my opinion would be through a REST API (http request). There are some tools in different languages to create REST endpoints easily and request REST endpoints.
For example, in python, you can request the content of a URL like this:
What is the quickest way to HTTP GET in Python?
But it depends on what you have on the C# side. Can you update the C# code?
Here are a range of solutions:
REST API: need to expose REST endpoints on the communicating "service".
in C#: https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api
in python, I would recommend django framework if you need to create a server (but if the python only request things and don't serve as a server, you may not need it)
message queue like rabbitmq or zeromq, but it requires an external service to manage queues and messages
TCP/IP socket like you suggested, but it requires to manage yourself those connections
I have been looking for ways to provide analytics for an app which is powered by REST server written in NodeJs and MySQL. Discovered OLAP which can actually make this much easier.
And found a python library that provides an OLAP HTTP server called 'Slicer'
http://cubes.databrewery.org/
Can someone explain how this works? Does this mean I have to update my schema. And create what is called fact tables?
Can this be used in conjunction with my NodeJS App? Any examples? Since I have only created single server apps. Would python reside on the same nodejs server. How will it start? ('forever app.js' is my default script)
If I cant use python since I have no exp, what are basics to do it in Nodejs?
My model is basically list of words, so the olap queries I have are words made in days,weeks,months of length 2,5,10 letters in languages eng,french,german etc
Ideas, hints and guidance much appreciated!
As you found out, CUbes provides an HTTPS OLAP server (the slicer tool).
Can someone explain how this works?
As an OLAP server, you can issue OLAP queries to the server. The API is REST/JSON based, so you can easily query the server from Javascript, nodejs, Python or any other language of your choice via HTTP.
The server can answer OLAP queries. OLAP queries are based on a model of "facts" and "dimensions". You can for example query "the total sales amount for a given country and product, itemized by moonth".
Does this mean I have to update my schema. And create what is called fact tables?
OLAP queries are is built around the Facts and Dimension concepts.
OLAP-oriented datawarehousing strategies often involve the creation of these Fact and Dimension tables, building what is called a Star Schema or a Snowflake Schema. These schemas offer better performance for OLAP-type queries on relational databases. Data is often loaded by what is called an ETL process (it can be a simple script) that loads data in the appropriate form.
The Python Cubes framework, however, does not force you to alter your schema or create an alternate one. It has a SQL backend which allows you to define your model (in terms of Facts and Dimensions) without the need of changing the actual database model. This is the documentation for the model definition: https://pythonhosted.org/cubes/model.html .
However, in some cases you may still prefer to define a schema for Data Mining and use a transformation process to load data periodically. It depends on your needs, the amount of data you have, performance considerations, etc...
With Cubes you can also use other non RDBMS backends (ie MongoDB), some of which offer built-in aggregation capabilities that OLAP servers like Cubes can leverage.
Can this be used in conjunction with my NodeJS App?
You can issue queries to your Cubes Slicer server from NodeJS.
Any examples?
There is a Javascript client library to query Cubes. You probably want to use this one: https://github.com/Stiivi/cubes.js/
I don't know of any examples using NodeJS. You can try to get some inspiration from the included AngularJS application in Cubes (https://github.com/Stiivi/cubes/tree/master/incubator). Another client tool is CubesViewer which may be of use to you while building your model: http://jjmontesl.github.io/cubesviewer/ .
Since I have only created single server apps. Would python reside on the same nodejs server. How will it start? ('forever app.js' is my default script)
You would run Cubes Slicer server as a web application (directly from your web server, ie. Apache). For example, with Apache, you would use apache-wsgi mod which allows to serve python applications.
Slicer can also run as a small web server in a standalone process, which is very handy during development (but I wouldn't recommend for production environments). In this case, it will be listening on a different port (typically: http://localhost:5000 ).
If I cant use python since I have no exp, what are basics to do it in Nodejs?
You don't really need to use Python at all. You can configure and use Python Cubes as OLAP server, and run queries from Javascript code (ie. directly from the browser). From the client point of view, is like a database system which you can query via HTTP and get responses in JSON format.
I need a sort of consultation. I am building a web app in django(hosted in heroku) which need to communicate with 100 of embedded devices(writing in C++/C). The embedded devices send data(50kb) to the web app and the web app present this information in a form of graphs.
My concern is , is it wise to build a python polling system(Socket communication) in the server side ?
Or is it Error-prone and I should use services like CloudMQTT?
Thank you in advance for your answers.
Unless you wanna have another project on your hands, it'd be best to use a dedicated library.
This isn't python specific, but I feel like you could achieve your goal relatively easy with a simple ajax request.
Check out The WebSocket API.
EDIT:
Upon further reading I found the Python port of websockets
My friend has a website built using Pyramid framework and using MongoDB to store data. If I want to build an iPhone app, how do I access the data from that database?
I know Obj-C and have built simple, iOS apps, but none of them used non-local data. I've googled but no good result returned. I just don't know where to start. Any good tutorial or sample code on the related issue would be appreciated!!
As far as best practices go, you would not want to be accessing MongoDB (or any database) directly over the internet without appropriate security considerations.
The most straightforward option from iOS would probably be either add a RESTful interface to your own application, or use a third party hosted solution that provides an API. In either case I would recommend using https in addition to authentication, as the MongoDB wire protocol is not currently encrypted.
For iOS I would consider using the RestKit framework as a handy helper. It includes reasonable documentation and examples to get you started.