-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.py
More file actions
50 lines (39 loc) · 1.26 KB
/
Copy pathapp.py
File metadata and controls
50 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# python app.py
# https://github.com/arshadansari27/flask-image-server/blob/master/app.py
# http://zetcode.com/python/flask/
import serial
from flask import Flask, send_file
from flask import request
# ATENÇÃO: Trocar a porta serial para a porta serial onde o Arduino está conectado
ser = serial.Serial('COM7', baudrate=500000, timeout=10)
# ATENÇÃO: Comentar a linha se estiver no Linux (Ubuntu 16.04 LTS)
ser.set_buffer_size(rx_size = 25600, tx_size = 12800)
app = Flask(__name__)
@app.route('/')
def hello():
filename = 'LabUno4.htm'
return send_file(filename, mimetype='text/html')
@app.route('/LabUno4a.htm')
def LabUno4a():
filename = 'LabUno4a.htm'
return send_file(filename, mimetype='text/html')
@app.route("/LabUno4.jpg")
def LabUno4():
filename = 'LabUno4.jpg'
return send_file(filename, mimetype='image/jpg')
@app.route('/js')
def js():
data="{}"
command = request.query_string
#print (command)
if command!=b'':
ser.write(command)
ser.write(b'\r')
ser.write(b'\n')
data = ser.readline()
#print (data)
return data
if __name__ == '__main__':
#app.run(host="127.0.0.1", port=5000)
app.run(host="127.0.0.1", port=80)
ser.close()