import os from flask import ( Flask, render_template, send_from_directory, request, make_response, redirect, ) from flask_basicauth import BasicAuth ASSETS_DIR = os.path.dirname(os.path.abspath(__file__)) app = Flask(__name__, static_folder='static') app.config['BASIC_AUTH_USERNAME'] = 'salt' app.config['BASIC_AUTH_PASSWORD'] = 'shaker' app.config['BASIC_AUTH_FORCE'] = True basic_auth = BasicAuth(app) @app.before_request def before_request(): if not request.is_secure: url = request.url.replace('http://', 'https://', 1) code = 301 return redirect(url, code=code) @app.route('/robots.txt') def static_from_root(): return send_from_directory(app.static_folder, request.path[1:]) @app.route('/demos/voice_generation') def voice_generation(): return render_template('gradio_demo.html', iframe="https://saltshaker.ai:7860/", title="Voice Generation") @app.route('/demos/speech_enhancement') def speech_enhancement(): return render_template('gradio_demo.html', iframe="https://saltshaker.ai:7861/", title="Speech Enhancement") @app.route('/demos/speech_separation') def speech_separation(): return render_template('gradio_demo.html', iframe="https://saltshaker.ai:7862/", title="Speech Separation") @app.route('/demos/noise_suppression') def noise_suppression(): return render_template('gradio_demo.html', iframe="https://saltshaker.ai:7863/", title="Noise Suppression") @app.route('/demos/paper_browser') def paper_browser(): return render_template('paper_browser.html', title="arXiv paper browser") @app.route('/') def index(): resp = make_response(render_template('index.html')) resp.headers.set('X-Robots-Tag', 'none') return resp if __name__ == '__main__': context = ('cert/383fff33778762e8.crt', 'cert/383fff33778762e8.key') app.run(host='0.0.0.0', port=443, ssl_context=context)