On save upload to pico
This commit is contained in:
16
editor.py
16
editor.py
@@ -5,6 +5,17 @@ from pygame import Color, Rect
|
|||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
import datetime
|
import datetime
|
||||||
import array
|
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
|
# Initialize pygame
|
||||||
pygame.init()
|
pygame.init()
|
||||||
@@ -120,6 +131,11 @@ while running:
|
|||||||
with open(filename, "wb") as file:
|
with open(filename, "wb") as file:
|
||||||
file.write(bitstream)
|
file.write(bitstream)
|
||||||
|
|
||||||
|
upload_file("http://192.168.1.106", "art.grb")
|
||||||
|
print("Uploaded")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(f"Pixel art saved as {filename}!")
|
print(f"Pixel art saved as {filename}!")
|
||||||
|
|
||||||
if event.key == K_u and pygame.key.get_mods() & KMOD_CTRL:
|
if event.key == K_u and pygame.key.get_mods() & KMOD_CTRL:
|
||||||
|
Reference in New Issue
Block a user