Category : python

I have a curl code generated through Insomnia which is working fine. I just can’t figure out to replicate It with python request. curl –request POST –url MY_SERVER_URL –header ‘Accept: application/json’ –header ‘Content-type: multipart/form-data; boundary=—011000010111000001101001’ –header ‘Authorization: AUTH_TOKEN’ –form ‘operations={ "query": "mutation($file: Upload!, $path: String!, $private: Boolean) { uploadFile(file: $file, path: $path, private: $private) }", ..

Read more

Xampp runs on my windows machine ( on d-disk) Downloaded plugin: export-laravel-5-migrations from https://github.com/beckenrode/mysql-workbench-export-laravel-5-migrations/blob/master/export-laravel-5-migrations.py After installing the plugin to Mysql-workbench, MYSQL workbench does not start anymore. Only when I remove the plugin from /users/xxx/appdata/ropaming/mysql/workbench/modules workbench can start up again. Event viewer log on windows: Faulting application name: MySQLWorkbench.exe, version: 8.0.25.0, time stamp: 0x6089097e Faulting module ..

Read more

I have been a Laravel developer for the past years, and I made most of my projects using Laravel. But now I’m working on a project that it needs a recommendation system and after looking around the web I found out that there’s no Laravel package for this purpose and the best thing to do ..

Read more

I have this code in Python (is interesterd poart of the code) elements = [{‘id’: 1, ‘name’: ‘Alex’}, {‘id’: 2, ‘name’: ‘Jessica’}] elements_json = json.dumps(elements) requests.post(‘http://localhost:8000/api/add-element’, data = {‘json’: elements_json}) Elements sometimes contain more elements. In PHP (Laravel) I have this code: public function Store(Request $request) { $json = json_decode($request->json ); echo $json; } I ..

Read more

I’m calling a python api via my CMD. @app.route("/getResult", methods = [‘GET’, ‘POST’]) def funcName(): print("Fetching the passed input file") f = request.files[‘data’] print("Reading the file using pandas") data = pd.read_csv(f) This is how i call it in cmd and it returns just a number output. curl -F [email protected]_sample.csv localhost:5000/getResult I’m trying to call it ..

Read more

I’m working on create a Parapharser with PHP, laravel and Vuejs, like (https://smodin.me/free-english-rewriter-and-spinner) I’m trying using a Traductor, for example, passing the introduced text from spanish to russian and return to spanish. But if i have 1 000 000 000 characters by day it’s expensive with google traductor api. Also i’ve trying to user a ..

Read more

My company works in laravel. They wanted a code for image masking for which I have created a python script. And then, they asked me to create an API for it. So, I used fastapi for creating an API. Now, the issue is I want to send an image file from laravel to my python ..

Read more

I am trying to run a python script from laravel using process but it is not working. My code: $process = new Process([‘C:/Users/hrish/AppData/Local/Programs/Python/Python39/python.exe’, ‘C:xampphtdocsNMovieRSystemappModelstop_movies.py’]); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } Error: SymfonyComponentProcessExceptionProcessFailedException The command ""C:/Users/hrish/AppData/Local/Programs/Python/Python39/python.exe" C:xampphtdocsNMovieRSystempublictop_movies.py" failed. Exit Code: 1(General error) Working directory: C:xampphtdocsNMovieRSystempublic Output: ================ Error Output: ================ Fatal Python error: _Py_HashRandomization_Init: ..

Read more

I’m trying to run, from a Laravel controller, a python script located inside the project dir, but symphony/process keeps generating an error/exception. $extension = ‘pdf’; $filename = rand(11111111, 99999999). ‘.’ . $extension; $request->file(‘centrale_rischi’)->move( base_path() . ‘/public/pdfcr/’, $filename ); $filePath = base_path() . ‘/public/pdfcr/’.$filename; $process = new Process([‘python’, ‘crExtractor.py’, $filePath]); $process->setTimeout(500); try { $process->run(); if(!$process->isSuccessful()){ throw ..

Read more

I am trying to execute a python script in Laravel using Symfony. I got this error. I have tried : $process = new Process([‘…’], null, [‘ENV_VAR_NAME’ => ‘value’]); The ENV_VAR_NAME value is set to my python 39 directory. I’m on windows. Can anybody help me with this? I’ve tried this, $process = new Process([‘python’, ‘top_movies.py’],null,[‘ENV_VAR_NAME’ ..

Read more

I trying to make printify API auth in PHP. I have example in python, but I not getting right result. Can you explain me what I doing wrong ? Code in python import os import hmac def sha256hash(request): hash = hmac.new(os.environ[‘SECRET_TOKEN’].encode(‘utf-8’), request.data.encode(‘utf-8’), ‘sha256’) return ‘sha256=’ + hash.hexdigest() def secure_compare(a, b): return hmac.compare_digest(a, b) print(‘%r’ % ..

Read more

python code is mytrends=[] abc = api.trends_place(234243454) for value in abc: for trend in value[‘trends’]: mytrends.append(trend[‘name’]) print(mytrends) while laravel code looks like this $command = escapeshellcmd(‘python D:/attachments/trends.py’); $output = shell_exec($command); echo $output; The output is nothing , dd() shows NULL . Kindly help Sourc..

Read more

I am running a python script in Laravel using the new Process and process->run() method. $process = new Process([‘python3’, ‘public/python/ARIMA/’ . $scriptName]); $process->setTimeout(180); $process->run(); The problem is that the process->run it throwing the following error: python3: can’t open file ‘public/python/ARIMA/KarlStorzARIMA.py’: [Errno 2] No such file or directory when I change the path and use the ..

Read more

$file = "D:/xampp/htdocs/crawlers/py/daraz.py"; $lines = file($file); $urlLine = $lines[5]; echo $urlLine; $hello = fopen($urlLine, "w") or die("Unable to open file!"); fwrite($hello,$dom); fclose($hello); This code is for getting url from my database instead of the python file in which the url is already placed hardcoded. Sourc..

Read more

I want to use a python script but appears the following error: python is not recognized as an internal or external command operable program or batch file $process = new Process([‘python’, ‘C:Test.py’]); $process->run(); // executes after the command finishes if (!$process->isSuccessful()) { echo $process->getErrorOutput(); } when i run the same command on cmd it works ..

Read more