java

How to make a JSON POST request from Java client to Python FastAPI server?

How to make a JSON POST request from Java client to Python FastAPI server? Question: I send a post request from a java springboot application like this: String requestBody = gson.toJson(sbert); System.out.println(requestBody); // If I print this, and use this in postman it works! HttpRequest add_request = HttpRequest.newBuilder() .uri(URI.create("http://localhost:4557/sbert_similarity")) .POST(HttpRequest.BodyPublishers.ofString(requestBody)) .header("Content-Type", "application/json") .build(); HttpResponse<String> response …

Total answers: 1

why exception is rised on some java files using JavaLang python package

why exception is rised on some java files using JavaLang python package Question: I am aiming to obtain all methods names in a java file and count theit lines of code. I actually managed to obtain something using the javalang parser for python. It identifies all methods but not creator which make me think there …

Total answers: 1

Adding a Substring to a String without knowing the position

Adding a Substring to a String without knowing the position Question: I want to add a char(newline) to a String by specifiying the location with a Substring. Is that possible in Python or Java? Here’s how I imagine it, Newline is added to the String at the position between two arrays ‘],’: str = [[a,b,c], …

Total answers: 1

executing java command from script gives error even though same command from cli works fine

executing java command from script gives error even though same command from cli works fine Question: I’m writing a python script that amongst other things launches a jar file. I’m using the following method to fire the java command: def first_launch(self): if self.is_initialize: subprocess.run( [f"-Xmx{self.max_memory}M", f"-Xms{self.min_memory}M", f"-jar server.jar", "nogui"], executable="/usr/bin/java", cwd=self.directory ) else: raise Exception("Server …

Total answers: 1

Pros/cons of defining a graph as nested node objects versus a dictionary?

Pros/cons of defining a graph as nested node objects versus a dictionary? Question: I am practicing a couple algorithms (DFS, BFS). To set up the practice examples, I need to make a graph with vertices and edges. I have seen two approaches – defining an array of vertices and an array of edges, and then …

Total answers: 1

Encrypting java JWEObject with RSA in python

Encrypting java JWEObject with RSA in python Question: I asked a while ago how to do something similar: Decrypting and encrypting java JWEObject with algorithm RSA-OAEP-256 on python Now I have a different encryption key and that code is not working for me anymore. I need to be able to encrypt my data: {"value": "Object …

Total answers: 1

Deserialize Nested Json Record From Postgres To POJO using Jackson

Deserialize Nested Json Record From Postgres To POJO using Jackson Question: I am preety new to Jackson and how it really works under the hood when its get complicated to an issue of what i am facing. I have a record coming from the database which is stored as JSON TYPE (using postgres). Below is …

Total answers: 3

Android's NfcA to python's pyscard (smartcard)

Android's NfcA to python's pyscard (smartcard) Question: I am backwards-engineering an android application (written in java) into a python application, where nfc (apdu) commands are sent. (ISO 14443-3A, if that helps) The android applications makes use of the android.nfc.tech.NfcA library and sends commands such as: import android.nfc.tech.NfcA; NfcA nfca_tag; byte[] message; message = nfca_tag.transceive(new byte[]{48, …

Total answers: 1

Raspberry Pi unable to connect to Windows Websocket

Raspberry Pi unable to connect to Windows Websocket Question: I am attempting to send data from a Python script running on a Raspberry Pi to a Java Micronaut ServerWebSocket running on a Windows machine, but I am getting asyncio.exceptions.TimeoutError errors during the process. I attempted to use the websockets library in Python on the Raspberry …

Total answers: 1

Calculating sequential move order from position matrix for Connect4 puzzle

Calculating sequential move order from position matrix for Connect4 puzzle Question: I wanted to know weather we can calculate the move order for a given Connect4 board, such that if the moves are played out sequentially from an empty board, we get the current position on board. Example: I have this position matrix for the …

Total answers: 2