On save upload to pico

This commit is contained in:
jimmy 2023-06-06 22:44:21 +12:00
parent fd4b2047ae
commit af251e7c5f
1 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,17 @@ from pygame import Color, Rect
from pygame.locals import *
import datetime
import array
import requests
def upload_file(url, filename):
with open(filename, "rb") as file:
response = requests.post(url, files={"file": file})
# Check the response status code and handle accordingly
if response.status_code == 200:
print("File upload successful")
else:
print("File upload failed")
# Initialize pygame
pygame.init()
@ -120,6 +131,11 @@ while running:
with open(filename, "wb") as file:
file.write(bitstream)
upload_file("http://192.168.1.106", "art.grb")
print("Uploaded")
print(f"Pixel art saved as {filename}!")
if event.key == K_u and pygame.key.get_mods() & KMOD_CTRL: