(Code below) Now you can turn Python into an API with code I wrote and then call it! This took me hours to make, special character combinations, skill, knowledge, and perseverance. (And 156 blocks) Prepare to be amazed. ⭐This project was not made all by me. All praise and credit and skill belongs to God. ⭐ (Info below) Just use the GET custom block when the server (code below) is running and it will output a response with no limit! Server instructions: BEFORE RUNNING, run "pip install scratchattach requests" on the command prompt. Then, just copy and paste this into a .py file (to run, use python path/to/python/file): import scratchattach, requests, getpass, time print("Press Ctrl+C to exit at any time.\n") server_type="" print("Scratch server or TurboWarp server?\n\nScratch saves history and requires signin.\n\ TurboWarp erases history after a while and works without an account, but the server is buggy with this!") while server_type not in ["scratch", "turbowarp"]: server_type=input("Which one? (turbowarp or scratch) ").lower() project_id=input("What's the project ID? ") if server_type=="turbowarp": conn=scratchattach.get_tw_cloud(project_id) else: sess=scratchattach.login(input("Enter your username: "), getpass.getpass("Password (Hides itself):")) conn=sess.connect_cloud(project_id) encoder=scratchattach.Encoding() def main(rors): count=1 try: print(f"Python server has {rors}!") while True: if conn.get_var("GET") not in ["0", 0, None]: message=encoder.decode(int(conn.get_var("GET"))) if message: output=requests.get(message) out=output.text while out!="": if len(out)>128: conn.set_var("GET", encoder.encode(out[0:123]+"._C.-")) out=out[123:len(out)] else: conn.set_var("GET", encoder.encode(out)) out="" time.sleep(3) else: conn.set_var("GET", encoder.encode("error")) time.sleep(3) conn.set_var("GET", "0") conn.disconnect() time.sleep(5) conn.reconnect() time.sleep(2) count+=1 if count>=10: conn.disconnect() time.sleep(5) conn.reconnect() count=1 except KeyboardInterrupt: if input("Press enter to stop, press r and enter to resume.") in ["r", "R", "resume"]: main("resumed") else: conn.disconnect() main(rors="started")
Uses @TimMcCool's Scratchattach and encoder. Finally! It works! Only uses a single cloud variable, which is probably part of why it took a long time, but it's DONE!!!