Run python script by PHP from another server - php

I am making APIs.
I'm using CentOS for web server, and another windows server 2016 for API server.
I'm trying to make things work between web server and window server.
My logic is like following flow.
1) Fill the data form and click button from web server
2) Send data to windows server
3) Python script runs and makes more data
4) More made data must send back to web server
5) Web server gets more made datas
6) BAMM! Datas append on browser!
I had made python scripts.
but I can't decide how to make datas go between two servers..
Should I use ajax Curl in web server?
I was planning to send a POST type request by Curl from web server to Windows server.
But I don't know how to receipt those datas in windows server.
Please help! Thank you in advance.

First option: (Recommended)
You can create the python side as an API endpoint and from the PHP server, you need to call the python API.
Second option:
You can create the python side just like a normal webpage and whenever you call that page from PHP server you pass the params along with HTTP request, and after receiving data in python you print the data in JSON format.

Related

Flutter web must I http to mysql

Good day. I am new to flutter web. If someone can assist or point me where I can get the correct info I would appreciate it. I need to save data in mysql on the same server that the flutter web app is uploaded to. What I want to know is if I must do a http request even though the mysql and webapp is on the same server? I guess I need to create a .php file to post and fetch data from the mysql database. But if you are on the same server do you http to the .php or is there another way? Thanks in advance.
If you meant with "HTTP to MySQL", to directly from Front-end access MySQL through some Web-API, then no there is no such thing supported by MySQL.
But you can create your own Web-API Back-end (a .php script), which redirects requests to MySQL, and then Front-end only needs to communicate with said Back-end.
The Front-end may seem to be on same server,
but the Front-end logic runs on the user's Browser, which is far away from server.

how to make server who receive file from android app?

I am android developer and zero at back end process. Whats stuff/tools require for making a server/website that receives files from android app. I listen somewhere that php code is required as backend on server side. Is is true?
hoping for detailed explanation. Sorry for my english.
Thanks.
need php file for coonecting with database.use phpmyadmin(xampp)
tool for creating database.then create phpfile n post on server or localhost. after that use url in android.like our php link is localhost:80/phpproj/trial.php
and pass value to database using asyctask method.

How can 2 different servers communicate in the same "machine"?

First of all i would like to apologize if my question doesnt make so much sense , as i am very new to these concepts.
We are building a mobile web application which has 2 parts.
1) The "back-end" server part which i am currently building , that is php-mysql , where i take care of all data to be stored in the database , i make queries etc.
2) The "front-end" part. This will be developed in jquery and will be the mobile web site. This "web site" will be available through a mobile application by opening an "in application browser" . Note that i ve never used jquery before. The architecture of the application was that every time a mobile phone connects to the web-site (jquery) , we send along with the URL the deviceID of the phone. Then when the user does anything at the site like subscribe to some kind of events , i "send" this subscriptions to my "back-end" server and save them to database.
My question :
As i said i dont know jquery. Both jquery and php will be deployed in the same machine. That means (i guess..) that i could through jquery have instant access to my databases and save users subscribtions. However because i dont know jquery i want to do the minimum staff with it. So i would like to pass these subscriptions to my php scripts and handle them there.
How do i "pass" the subscriptions between the 2 servers that are deployed in the same machine? Do i need to make an http post request? Thats what i do to make the mobile devices , connect with the server but i guess that when they are in the same machine there should be another way right? We use HTTP requests for remote connections right?
Even though jQuery and PHP are hosted on the same machine, it is not executed on the same machine.
PHP is executed on the local machine and it's results are sent to the client (in app browser).
jQuery is sent to the client and executed at the client.
So PHP is executed on server and jQuery at client. To facilitate the communication you should use for example jQuery.ajax http://api.jquery.com/jQuery.ajax/ or for example jQuery.getJSON http://api.jquery.com/jQuery.getJSON/

Javascript IPhone Application send request or information to server PHP file

Hello i have iphone app now i want to send request or data to server or PHP file.
Please note: the php file is on another server not on the same server.
How can i send data to server using javascript ?
The fastest and easiest solution would be including jQuery and use it's post method; http://api.jquery.com/jQuery.post/

PHP code safeguard technique for Remote call, scenario based

I am thinking about safeguardimg my php code in a different way for my project, but it may be childish method. Please let me know alternative or pros and cons of this method.
Both client and server has LAMP.
Client system holds client sensitive data, which will not be shared to the server.
Client will have Auth key to access server.
When client requests the server using the Auth key, after server verifies it, server will send the php code to client for the execution. The Php code will be executed in client and it will connect to other sites from client for processing.
Client will use remote include to get code and execute.
<?php include('http://www.example.com/clientCode.php'); ?>
Client side files is provided by Server admin, with ioncube or zend safeguard encoded one.
So they will not know the PHP code (my assumption).
Also client server interaction will be processed through secure connection.
Including the remote file like that might not work as expected, as the included file is actually executed on the remote server and the result is included in the script that invokes it, not the the actually PHP code from the included file.
If that is what you wish, then that's ok; but you can't transfer the actual PHP code from the remote server.
However, if you MUST transfer the actual code from the remote server to the client, than you could create an API that takes care of the authentication and authorization of the client, reads (without interpreting) the desired PHP file, and then sends it to the client. You could then either eval the code, or cache it as a local file on the client.
You will need special encryption software like Zend Guard if you want to protect your code from your clients.

Categories