-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (22 loc) · 658 Bytes
/
app.py
File metadata and controls
30 lines (22 loc) · 658 Bytes
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
from flask import Flask, render_template, request
import posix_ipc
app = Flask(__name__)
try:
mq = posix_ipc.MessageQueue("/webtext_ipc")
mq.block = False
except posix_ipc.PermissionsError:
print("couldn't open message queue")
exit(1)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
mq.send(request.form["text"], timeout=10)
return render_template('confirm.html')
else:
return render_template('index.html')
@app.route('/test')
def hello_world():
mq.send('Hello World!', timeout=10)
return 'Hello World!'
if __name__ == '__main__':
app.run(host='0.0.0.0')