-
Notifications
You must be signed in to change notification settings - Fork 1
Python Applications
XHiddenProjects edited this page Aug 13, 2024
·
2 revisions
This will talk about how to make your own Python application
- Create a Python file in the
scripts/{app_file.py}
and a JSON configuration file inscripts/data/{app_file.json}
- 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!
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));
}
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;