uploaded images saved to Pi
This commit is contained in:
parent
3fb1ee197a
commit
acd46c0aef
@ -613,8 +613,6 @@ if __name__ == '__main__':
|
||||
#f.close()
|
||||
|
||||
|
||||
updateWeather()
|
||||
sys.exit()
|
||||
try:
|
||||
f = open('csv/last_updates.json', 'r')
|
||||
last_updates = json.load(f)
|
||||
|
@ -1 +1 @@
|
||||
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["image.gif"]}
|
||||
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["open.gif"]}
|
@ -1 +1 @@
|
||||
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["ZM.png", "WORK.png"]}
|
||||
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["XOM.png", "ZBRA.png"]}
|
Binary file not shown.
4
log.txt
4
log.txt
@ -1,4 +1,4 @@
|
||||
[Errno 2] No such file or directory: '/home/pi/Desktop/stock_ticker/ZM.png'. file: stockTicker.py. line: 2230. type: <class 'FileNotFoundError'>
|
||||
[Errno 2] No such file or directory: '/home/pi/Desktop/stock_ticker/XOM.png'. file: stockTicker.py. line: 2230. type: <class 'FileNotFoundError'>
|
||||
Traceback (most recent call last):
|
||||
File "stockTicker.py", line 2230, in <module>
|
||||
stock_ticker.process_msg(msg)
|
||||
@ -14,4 +14,4 @@
|
||||
image = Image.open(image_file)
|
||||
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2634, in open
|
||||
fp = builtins.open(filename, "rb")
|
||||
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/Desktop/stock_ticker/ZM.png'
|
||||
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/Desktop/stock_ticker/XOM.png'
|
||||
|
22
server.py
22
server.py
@ -367,6 +367,28 @@ def feature_settings():
|
||||
|
||||
return index()
|
||||
|
||||
# saves files uploaded to the webpage for images and GIFs
|
||||
@app.route("/upload", methods = ['PUT', 'POST', 'GET'])
|
||||
def upload():
|
||||
|
||||
|
||||
try:
|
||||
|
||||
|
||||
images = request.files
|
||||
names = list(request.files.keys())
|
||||
for name in names:
|
||||
images[name].save('user_uploads/' +name)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
|
||||
return index()
|
||||
|
||||
|
||||
|
||||
def combine_dict(current_settings, input_symbols, current_key):
|
||||
# removes keys not in input from current_settings[current_key] and adds keys not in current from input
|
||||
|
@ -486,11 +486,22 @@ var allFeaturesFileAddBtn = [
|
||||
null,
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
var uploaded_images = [];
|
||||
var uploaded_GIFs = [];
|
||||
|
||||
allFeaturesFileAddBtn.map((value, index) => {
|
||||
if (value !== null) {
|
||||
value.addEventListener("click", () => {
|
||||
var tag = document.createElement("li");
|
||||
tag.innerHTML = allFeaturesFile[index].files[0].name;
|
||||
if (index == 10) {
|
||||
uploaded_images.push(allFeaturesFile[index].files[0]);
|
||||
} else if (index == 11) {
|
||||
uploaded_GIFs.push(allFeaturesFile[index].files[0]);
|
||||
}
|
||||
|
||||
allFeatures[index].appendChild(tag);
|
||||
changeVarValue();
|
||||
@ -685,6 +696,35 @@ function saveSettings() {
|
||||
method:"PUT",
|
||||
body:JSON.stringify(settings)
|
||||
});
|
||||
|
||||
//send uploaded images and gifs
|
||||
if (pageNum == 11){
|
||||
var data = new FormData();
|
||||
|
||||
for ( var i = 0; i < uploaded_images.length; i++ ) {
|
||||
data.append(uploaded_images[i].name, uploaded_images[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
fetch("/upload", {
|
||||
method:"POST",
|
||||
body:data
|
||||
});
|
||||
|
||||
|
||||
} else if (pageNum == 12) {
|
||||
var data = new FormData();
|
||||
|
||||
for ( var i = 0; i < uploaded_GIFs.length; i++ ) {
|
||||
data.append(uploaded_GIFs[i].name, uploaded_GIFs[i]);
|
||||
}
|
||||
|
||||
fetch("/upload", {
|
||||
method:"POST",
|
||||
body:data
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let saveSettingsButtons = document.querySelectorAll(".save-btn-div").forEach(button =>
|
||||
|
BIN
user_uploads/XOM.png
Normal file
BIN
user_uploads/XOM.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
user_uploads/ZBRA.png
Normal file
BIN
user_uploads/ZBRA.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
user_uploads/open.gif
Normal file
BIN
user_uploads/open.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
Loading…
Reference in New Issue
Block a user