image and gif upload and display working
This commit is contained in:
parent
b511b4f69e
commit
29784eed4f
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
name,current,24hr change
|
||||
bitcoin,50378,0.18956930030648758
|
||||
ethereum,4007.97,4.564560454952176
|
||||
bitcoin,40905,1.9630605505752174
|
||||
ethereum,2756.88,2.711695798229129
|
||||
|
|
@ -1 +1 @@
|
||||
hello world!,255,255,0
|
||||
ARUSHI IS CUTE,0,0,255
|
|
@ -1,2 +1,2 @@
|
||||
speed,brightness
|
||||
s,5
|
||||
m,5
|
|
BIN
display_gif
Normal file
BIN
display_gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
BIN
display_image
Normal file
BIN
display_image
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
final1.ppm
BIN
final1.ppm
Binary file not shown.
BIN
gifs/close.gif
Normal file
BIN
gifs/close.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 821 B |
BIN
gifs/open.gif
Normal file
BIN
gifs/open.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
BIN
scroll_text.ppm
BIN
scroll_text.ppm
Binary file not shown.
67
server.py
67
server.py
@ -137,15 +137,58 @@ def Brightness():
|
||||
LastCommand = 'Change Brightness'
|
||||
return hello()
|
||||
|
||||
@app.route("/Display_text", methods=['POST'])
|
||||
def Display_text():
|
||||
@app.route("/DisplayText", methods=['POST'])
|
||||
def DisplayText():
|
||||
text = request.form['text']
|
||||
f = open('csv/scroll_text.csv', 'w+')
|
||||
f.write(text)
|
||||
f.close()
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('T')
|
||||
return hello()
|
||||
|
||||
@app.route("/DisplayImage", methods=['POST'])
|
||||
def DisplayImage():
|
||||
if request.method == 'POST':
|
||||
if 'file' not in request.files:
|
||||
print('No file attached in request')
|
||||
return hello()
|
||||
fle = request.files['file']
|
||||
if fle.filename == '':
|
||||
print('No file selected')
|
||||
return hello()
|
||||
if fle and allowed_file(fle.filename):
|
||||
filename = 'display_image'
|
||||
fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), filename))
|
||||
global LastCommand
|
||||
LastCommand = 'Add a new logo file'
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('I')
|
||||
return hello()
|
||||
return hello()
|
||||
|
||||
@app.route("/DisplayGIF", methods=['POST'])
|
||||
def DisplayGIF():
|
||||
|
||||
if request.method == 'POST':
|
||||
if 'file' not in request.files:
|
||||
print('No file attached in request')
|
||||
return hello()
|
||||
fle = request.files['file']
|
||||
if fle.filename == '':
|
||||
print('No file selected')
|
||||
return hello()
|
||||
if fle:
|
||||
print('in')
|
||||
filename = 'display_gif'
|
||||
fle.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), filename))
|
||||
global LastCommand
|
||||
LastCommand = 'Add a new logo file'
|
||||
ticker.sendline('K')
|
||||
ticker.sendline('G')
|
||||
return hello()
|
||||
return hello()
|
||||
|
||||
|
||||
@app.route("/Ticker", methods=['POST'])
|
||||
def Ticker():
|
||||
@ -153,13 +196,13 @@ def Ticker():
|
||||
if 'file' not in request.files:
|
||||
print('No file attached in request')
|
||||
return hello()
|
||||
file = request.files['file']
|
||||
if file.filename == '':
|
||||
fle = request.files['file']
|
||||
if fle.filename == '':
|
||||
print('No file selected')
|
||||
return hello()
|
||||
if file and allowed_file(file.filename):
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join(CSV_FOLDER, filename))
|
||||
if fle and allowed_file(fle.filename):
|
||||
filename = secure_filename(fle.filename)
|
||||
fle.save(os.path.join(CSV_FOLDER, filename))
|
||||
process_file(os.path.join(CSV_FOLDER, filename), filename)
|
||||
global LastCommand
|
||||
LastCommand = 'Change CSV file'
|
||||
@ -172,13 +215,13 @@ def AddLogo():
|
||||
if 'file' not in request.files:
|
||||
print('No file attached in request')
|
||||
return hello()
|
||||
file = request.files['file']
|
||||
if file.filename == '':
|
||||
fle = request.files['file']
|
||||
if fle.filename == '':
|
||||
print('No file selected')
|
||||
return hello()
|
||||
if file and allowed_file(file.filename):
|
||||
filename = secure_filename(file.filename)
|
||||
file.save(os.path.join(LOGO_FOLDER, filename))
|
||||
if fle and allowed_file(fle.filename):
|
||||
filename = secure_filename(fle.filename)
|
||||
fle.save(os.path.join(LOGO_FOLDER, filename))
|
||||
global LastCommand
|
||||
LastCommand = 'Add a new logo file'
|
||||
return hello()
|
||||
|
@ -182,6 +182,37 @@ class StockTicker():
|
||||
self.scrollImageTransition(['scroll_text.ppm', 'scroll_text.ppm'], offset_x = 128, offset_y = 0, stocks = False)
|
||||
|
||||
|
||||
def displayGIF(self, gif_file):
|
||||
|
||||
im = Image.open(gif_file)
|
||||
|
||||
# To iterate through the entire gif
|
||||
|
||||
i = 0
|
||||
while 1:
|
||||
print(im.tell())
|
||||
try:
|
||||
im.seek(i)
|
||||
except EOFError:
|
||||
print('finished')
|
||||
i = 0
|
||||
im.seek(i)
|
||||
# do something to im
|
||||
self.setImage(im.convert('RGB'))
|
||||
time.sleep(0.5)
|
||||
i += 1
|
||||
try:
|
||||
msg = getInput()
|
||||
if msg == 'K':
|
||||
self.resetMatrix()
|
||||
break
|
||||
|
||||
self.process_msg(msg)
|
||||
except KeyboardInterrupt:
|
||||
sys.stdout.flush()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
#Using change between min and day price give appropriate arrow
|
||||
#and set the overall change colour
|
||||
@ -406,11 +437,11 @@ class StockTicker():
|
||||
|
||||
def process_msg(self, msg):
|
||||
|
||||
if msg == 'S':
|
||||
if msg == 'S': # stocks
|
||||
self.getFullStockImage(1)
|
||||
self.displayStocks()
|
||||
|
||||
|
||||
# speed settings
|
||||
elif msg == 's':
|
||||
self.delay = 0.03
|
||||
|
||||
@ -420,16 +451,36 @@ class StockTicker():
|
||||
elif msg == 'f':
|
||||
self.delay = 0.005
|
||||
|
||||
elif msg in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
|
||||
|
||||
elif msg in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: # birghtness ettings
|
||||
|
||||
self.brightness = min(1.0, float(msg)/10 + 0.1)
|
||||
elif msg == 'T':
|
||||
|
||||
|
||||
elif msg == 'T':# text
|
||||
|
||||
self.displayText()
|
||||
|
||||
elif msg == 'I': # image
|
||||
|
||||
image = self.openImage(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_image'))
|
||||
self.setImage( image)
|
||||
|
||||
elif msg == 'G': # gif
|
||||
|
||||
self.displayGIF(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'display_gif'))
|
||||
|
||||
|
||||
elif msg == 'K': # kill
|
||||
self.resetMatrix()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
#print(sys.stdin.readlines())
|
||||
stock_ticker = StockTicker()
|
||||
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/open.gif')
|
||||
#stock_ticker.displayGIF('/home/pi/Desktop/stock_ticker/gifs/close.gif')
|
||||
|
||||
|
||||
#stock_ticker.process_msg(brightness)
|
||||
#stock_ticker.process_msg(speed)
|
||||
|
BIN
stockTicker.pyc
BIN
stockTicker.pyc
Binary file not shown.
@ -30,11 +30,23 @@
|
||||
</form>
|
||||
|
||||
<p>Display scrolling text. Enter the message followed by the rgb values seperated by commas. e.g. hello world!,255,255,0</p>
|
||||
<form action="/Display_text" method="POST">
|
||||
<form action="/DisplayText" method="POST">
|
||||
<input name="text" placeholder="hello world!,255,255,0"style="height:24px">
|
||||
<input type="submit" value="Display"style="height:30px">
|
||||
</form>
|
||||
|
||||
<p>Display an image</p>
|
||||
<form action="/DisplayImage" method="POST" enctype=multipart/form-data>
|
||||
<p><input type=file name=file style="height:30px">
|
||||
<input type=submit value=Upload style="height:30px">
|
||||
</form>
|
||||
|
||||
<p>Display a gif</p>
|
||||
<form action="/DisplayGIF" method="POST" enctype=multipart/form-data>
|
||||
<p><input type=file name=file style="height:30px">
|
||||
<input type=submit value=Upload style="height:30px">
|
||||
</form>
|
||||
|
||||
<br><br>
|
||||
<h3>Tickers to display</h3>
|
||||
<p>To change the tickers displayed please upload a CSV (comma separated value) file with 11 tickers on each row e.g</p>
|
||||
|
Loading…
Reference in New Issue
Block a user