On save upload to pico
This commit is contained in:
parent
fd4b2047ae
commit
af251e7c5f
16
editor.py
16
editor.py
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue