|
| 1 | +import requests |
| 2 | +from requests.auth import HTTPBasicAuth |
| 3 | + |
| 4 | +IP = "192.168.1.79" |
| 5 | +PORT = 80 |
| 6 | + |
| 7 | +IP = "funhouse" |
| 8 | +PORT = 8080 |
| 9 | + |
| 10 | +auth = HTTPBasicAuth("", "passw0rd") |
| 11 | + |
| 12 | +############################################################ |
| 13 | + |
| 14 | +with requests.options( |
| 15 | + f"http://{IP}:{PORT}/fs/", |
| 16 | + headers={ |
| 17 | + "Accept": "application/json", |
| 18 | + }, |
| 19 | + auth=auth |
| 20 | + ) as r: |
| 21 | + print("-"*70) |
| 22 | + print(" ", r.status_code) |
| 23 | + print(r.content) |
| 24 | + print(r.headers) |
| 25 | + |
| 26 | +""" |
| 27 | +print("Reading /fs/") |
| 28 | +
|
| 29 | +with requests.get( |
| 30 | + f"http://{IP}:{PORT}/fs/", |
| 31 | + headers={"Accept": "application/json"}, |
| 32 | + auth=auth |
| 33 | + ) as r: |
| 34 | + print("-"*70) |
| 35 | + print(" ", r.status_code) |
| 36 | + print(r.json()) |
| 37 | +
|
| 38 | +with requests.options( |
| 39 | + f"http://{IP}:{PORT}/fs/", |
| 40 | + headers={"Accept": "application/json"}, |
| 41 | + auth=auth |
| 42 | + ) as r: |
| 43 | + print("-"*70) |
| 44 | + print(" ", r.status_code) |
| 45 | + print(r.content) |
| 46 | + print(r.headers) |
| 47 | +
|
| 48 | +with requests.get( |
| 49 | + f"http://{IP}:{PORT}/cp/version.json", |
| 50 | + headers={"Accept": "application/json"}, |
| 51 | + auth=auth |
| 52 | + ) as r: |
| 53 | + print("-"*70) |
| 54 | + print(" ", r.status_code) |
| 55 | + print(r.content) |
| 56 | + print(r.headers) |
| 57 | +
|
| 58 | +with requests.get( |
| 59 | + f"http://{IP}:{PORT}/fs/lib/", |
| 60 | + headers={"Accept": "application/json"}, |
| 61 | + auth=auth |
| 62 | + ) as r: |
| 63 | + print("-"*70) |
| 64 | + print(" ", r.status_code) |
| 65 | + print(r.json()) |
| 66 | +""" |
| 67 | + |
| 68 | +############################################################ |
| 69 | + |
| 70 | +# print("Creating a test dir") |
| 71 | +# |
| 72 | +# with requests.put( |
| 73 | +# f"http://{IP}:{PORT}/fs/test/", |
| 74 | +# auth=auth |
| 75 | +# ) as r: |
| 76 | +# print(" ", r.status_code) |
| 77 | + |
| 78 | +# print("delete the directory for tests") |
| 79 | +# |
| 80 | +# with requests.delete( |
| 81 | +# f"http://{IP}:{PORT}/fs/test/", |
| 82 | +# auth=auth |
| 83 | +# ) as r: |
| 84 | +# print(" ", r.status_code) |
| 85 | + |
| 86 | +############################################################ |
| 87 | + |
| 88 | +# print("Uploading a test file") |
| 89 | +# |
| 90 | +# with requests.put( |
| 91 | +# f"http://{IP}:{PORT}/fs/test.py", |
| 92 | +# 'print("Hello ESP32 V2!")', |
| 93 | +# auth=auth |
| 94 | +# ) as r: |
| 95 | +# print(" ", r.status_code) |
| 96 | + |
| 97 | +############################################################ |
| 98 | + |
| 99 | +# try: |
| 100 | +# print("Reading /fs/ a second time") |
| 101 | +# |
| 102 | +# with requests.get( |
| 103 | +# f"http://{IP}:{PORT}/fs/", |
| 104 | +# headers={"Accept": "application/json"}, |
| 105 | +# auth=auth |
| 106 | +# ) as r: |
| 107 | +# print(" ", r.status_code, "a file:", r.json()[0]["name"]) |
| 108 | +# except requests.exceptions.ConnectionError as ex: |
| 109 | +# print(" FAILED reading") |
| 110 | + |
0 commit comments