- 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>importos, jsoncurrentPath=os.getcwd() +"/data/{file.json}"withopen(currentPath) asjson_file:
data=json.load(json_file)
finalize= {}
# Content goes hereprint("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}
importEventsfrom"./Events.js";functionfunctionName(param){// Loads the events classconste=newEvents(),strify=JSON.stringify({"data":"goes here"});// Saving datae.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
constAPI=e.request(window.location.origin+'/WebServerAI/scripts/{app_file.py}',true);returnAPI;