Hi
im currently using Jupyter Notebook Server API to access my remote file.
However, i can’t execute remote py file using by using request.post() tho Jupyter Server API.
i already manage to create Terminal by:
import requests
import json
# link remote server
hostname = 'xx.xx.com'
port = '442'
password = 'xxx'
token = {'token':'xxx'}
base_url = 'https://{0}:{1}/'.format(hostname, port)
print (base_url)
h = {}
if password:
r = requests.post(base_url + 'login', params={
'password': password
})
h = r.request.headers
# sessions = requests.post(base_url + 'api/terminals', headers=h, params=token).json()
# print (sessions)
## create terminal
command = 'python /report/Remote-testcode.py'
# body = json.dumps(command)
body = json.dumps({'file_content':command})
sessions = requests.post(base_url + 'api/terminals',
data = body, headers=h, params=token) # .json
print(sessions)
but when i try to post my command ,it return <Response [404]>
script = '/report//Remote-testcode.py' # remote script path
command = f'python {script}'
data = {'data': command }
response = requests.post(f'{base_url}/api/terminals/{terminal_id}/send',
headers=h, params=token, data=json.dumps(data))
response
In conclusion, is there any way to post/put/send/uploade the command into the remote terminal and run it ?
Thanks in advance.