gunicorn?
This commit is contained in:
parent
ff31008e24
commit
37d9e3780f
5 changed files with 37 additions and 24 deletions
6
README
6
README
|
@ -3,3 +3,9 @@ HTTP Triggered Sample Player
|
|||
Absolutely no access control.
|
||||
Horribly insecure.
|
||||
Only use in internal networks.
|
||||
|
||||
can be started via:
|
||||
|
||||
```
|
||||
gunicorn --config gunicorn_config.py app:app
|
||||
```
|
||||
|
|
30
app.py
30
app.py
|
@ -1,26 +1,28 @@
|
|||
from playsound import playsound
|
||||
from flask import Flask
|
||||
from flask import render_template
|
||||
from markupsafe import escape
|
||||
from os import listdir
|
||||
from os.path import join
|
||||
|
||||
from flask import Flask, render_template
|
||||
from markupsafe import escape
|
||||
from playsound import playsound
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
samplefiles = listdir('samples')
|
||||
samplefiles = listdir("samples")
|
||||
samples = []
|
||||
for f in samplefiles:
|
||||
if '.wav' in f:
|
||||
samples.append(f.replace('.wav', ''))
|
||||
if ".wav" in f:
|
||||
samples.append(f.replace(".wav", ""))
|
||||
|
||||
@app.route('/')
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
return render_template('index.html', samples=samples)
|
||||
return render_template("index.html", samples=samples)
|
||||
|
||||
@app.route('/play/<sample>')
|
||||
|
||||
@app.route("/play/<sample>")
|
||||
def door(sample):
|
||||
if sample in samples:
|
||||
playsound(join('samples', f'{sample}.wav'))
|
||||
return f'<h1>{escape(sample)}!</h1>'
|
||||
playsound(join("samples", f"{sample}.wav"))
|
||||
return f"<h1>{escape(sample)}!</h1>"
|
||||
else:
|
||||
return 'no such sample'
|
||||
|
||||
return "no such sample"
|
||||
|
|
14
gunicorn_config.py
Normal file
14
gunicorn_config.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import os
|
||||
|
||||
workers = int(os.environ.get("GUNICORN_PROCESSES", "2"))
|
||||
|
||||
threads = int(os.environ.get("GUNICORN_THREADS", "4"))
|
||||
|
||||
# timeout = int(os.environ.get('GUNICORN_TIMEOUT', '120'))
|
||||
|
||||
bind = os.environ.get("GUNICORN_BIND", "0.0.0.0:8080")
|
||||
|
||||
|
||||
forwarded_allow_ips = "*"
|
||||
|
||||
#secure_scheme_headers = {"X-Forwarded-Proto": "https"}
|
|
@ -1,3 +1,3 @@
|
|||
Flask
|
||||
Gunicorn
|
||||
playsound
|
||||
pygobject
|
||||
|
|
9
wsgi.py
9
wsgi.py
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
import sys
|
||||
import logging
|
||||
logging.basicConfig(stream=sys.stderr)
|
||||
sys.path.insert(0,"/root/customer-account-automation/")
|
||||
|
||||
from app import app as application
|
||||
app = application
|
||||
|
Loading…
Reference in a new issue