-
Notifications
You must be signed in to change notification settings - Fork 32
Edited main.py and test.py #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,18 @@ | ||
| from cgi import test | ||
| import requests | ||
| import os | ||
| import urllib.request | ||
| import time | ||
|
|
||
| # function to test upload() method. | ||
| def upload(): | ||
| url = "http://127.0.0.1:5000/upload/test?apikey=xyz" | ||
|
|
||
| path = os.path.abspath("example.py") | ||
| def upload(files): | ||
| url = "http://127.0.0.1:5000/upload/test?apikey=xyz" | ||
|
|
||
| payload={} | ||
| files=[ | ||
| ('files[]',('example.py',open(path,'rb'),'application/octet-stream')) | ||
| ] | ||
| # files=[ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these commented out? |
||
| # ('files[]',('example.py',open(path,'rb'),'application/octet-stream')) | ||
| # ] | ||
| headers = {} | ||
|
|
||
| response = requests.request("POST", url, headers=headers, data=payload, files=files) | ||
|
|
@@ -21,50 +22,46 @@ def upload(): | |
|
|
||
| # # ******* | ||
|
|
||
| # function to test execute() method. | ||
| def execute(): | ||
| url = "http://127.0.0.1:5000/execute/test?apikey=xyz" | ||
|
|
||
| path = os.path.abspath("example.py") | ||
|
|
||
| payload={} | ||
| files=[ | ||
| ('file',('example.py',open(path,'rb'),'application/octet-stream')) | ||
| ] | ||
| headers = {} | ||
|
|
||
| response = requests.request("POST", url, headers=headers, data=payload, files=files) | ||
|
|
||
| # function to check build | ||
| def build(dir, graphml, apikey): | ||
| url = "http://127.0.0.1:5000/build/"+dir+"?"+"fetch="+graphml+"&"+"apikey="+apikey | ||
| response = requests.request("POST", url) | ||
| print(response.text) | ||
|
|
||
| # function to test download() method. | ||
| def download(): | ||
| url = "http://127.0.0.1:5000/download/test?fetch=f1.txt&apikey=xyz" | ||
| urllib.request.urlretrieve(url, "f1.txt") | ||
| # function to debug | ||
| def debug(graphml): | ||
| url = "http://127.0.0.1:5000/debug/"+graphml | ||
| response = requests.request("POST", url) | ||
| print(response.text) | ||
|
|
||
| # function to test run() method. | ||
| def run(graphml): | ||
| url = "http://127.0.0.1:5000/run/"+graphml | ||
| response = requests.request("POST", url) | ||
| print(response.text) | ||
|
|
||
| # function to check build | ||
| def build(): | ||
| url = "http://127.0.0.1:5000/build/test?fetch=sample1" | ||
| def clear(graphml): | ||
| url = "http://127.0.0.1:5000/clear/"+graphml | ||
| response = requests.request("POST", url) | ||
| print(response.text) | ||
|
|
||
| # function to debug | ||
| def debug(): | ||
| url = "http://127.0.0.1:5000/debug/sample1" | ||
| def stop(graphml): | ||
| url = "http://127.0.0.1:5000/stop/"+graphml | ||
| response = requests.request("POST", url) | ||
| print(response.text) | ||
| print(response.text) | ||
|
|
||
|
|
||
| #function to destroy dir. | ||
| def destroy(): | ||
| url = "http://127.0.0.1:5000/destroy/sample1" | ||
| def destroy(dir): | ||
| url = "http://127.0.0.1:5000/destroy/" + dir | ||
| response = requests.request("DELETE", url) | ||
|
|
||
| print(response.text) | ||
|
|
||
| def getFilesList(): | ||
| url = "http://127.0.0.1:5000/getFilesList/test" | ||
| def getFilesList(dir): | ||
| url = "http://127.0.0.1:5000/getFilesList/" + dir | ||
| response = requests.request("POST", url) | ||
| print(response.text) | ||
|
|
||
|
|
@@ -73,13 +70,30 @@ def openJupyter(): | |
| response = requests.request("POST", url) | ||
| print(response.text) | ||
|
|
||
| # function to test download() method. | ||
| def download(): | ||
| url = "http://127.0.0.1:5000/download/test?fetch=f1.txt&apikey=xyz" | ||
| urllib.request.urlretrieve(url, "f1.txt") | ||
|
|
||
| # upload() | ||
| # execute() | ||
| # download() | ||
| # build() | ||
| # debug() | ||
| # destroy() | ||
| getFilesList() | ||
| # file list to be uploaded | ||
| files=[ | ||
| #('files[]',(file_name,open(file_path,'rb'),'application/octet-stream')) | ||
| ('files[]',('controller.py',open('/home/amit/Desktop/test_xyz/controller.py','rb'),'application/octet-stream')), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pls do not hard-code the values such as "/home/amit" as these will not work outside your computer. Use relative paths instead.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace '/home/amit/Desktop/test_xyz/controller.py' with '../demo/controller.py' |
||
| ('files[]',('pm.py',open('/home/amit/Desktop/test_xyz/pm.py','rb'),'application/octet-stream')), | ||
| ('files[]',('sample1.graphml',open('/home/amit/Desktop/test_xyz/sample1.graphml','rb'),'application/octet-stream')), | ||
| # ('files[]',('example.py',open('/home/amit/Desktop/fri/example.py','rb'),'application/octet-stream')) | ||
| ] | ||
|
|
||
|
|
||
| # upload(files) | ||
| # build("test", "sample1", "xyz") | ||
| # time.sleep(6) | ||
| # debug("sample1") | ||
| # run("sample1") | ||
| # clear("sample1") | ||
| # stop("sample1") | ||
| # getFilesList("sample1") | ||
| # destroy("sample1") | ||
| # openJupyter() | ||
| # download() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.