Skip to content

Python Applications

XHiddenProjects edited this page Aug 13, 2024 · 2 revisions

This will talk about how to make your own Python application

Creating an Application

  1. Create a Python file in the scripts/{app_file.py} and a JSON configuration file in scripts/data/{app_file.json}
  2. In the scripts/{app_file.py} you must have this following syntax
#! <Python compiler here>
import os, json

currentPath = os.getcwd() + "/data/{file.json}"

with open(currentPath) as json_file:
    data = json.load(json_file)
finalize = {}
# Content goes here



print("Content-Type: application/json\n")
print(json.dumps(finalize))

Note: the {app_file.json} is to receive information from the user

Now you have finished the Python portion!

Saving Data

To save the data go to your JavaScript file

APP_FILE_DATA_NAME is the file name of /scripts/data/{app_file.json}. DO NOT PLACE .json at the end of {JSON_FILE_NAME}

import Events from "./Events.js";
function functionName(param){
// Loads the events class
const e = new Events(),
  strify = JSON.stringify({"data":"goes here"});
// Saving data
e.request(window.location.origin+'/WebServerAI/libs/ai_script_data.php?'+encodeURIComponent('dataname={APP_FILE_DATA_NAME}&datasets='+strify));
}

Receiving Data

To receive data use this code. This goes into the same function after the Saving Data

const API = e.request(window.location.origin+'/WebServerAI/scripts/{app_file.py}',true);
return API;
Clone this wiki locally