Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
•
8a2e49f
1
Parent(s):
aa761a0
feat: force flask app on localhost if not within a docker contasiner
Browse files
webApp.py
CHANGED
@@ -2,7 +2,7 @@ import json
|
|
2 |
import os
|
3 |
import webbrowser
|
4 |
|
5 |
-
from aip_trainer import app_logger
|
6 |
from flask import Flask, render_template, request
|
7 |
from flask_cors import CORS
|
8 |
|
@@ -44,7 +44,8 @@ def GetAccuracyFromRecordedAudio():
|
|
44 |
if __name__ == "__main__":
|
45 |
is_docker_container = os.getenv("IS_DOCKER_CONTAINER", "").lower() == "yes"
|
46 |
app_logger.info(f"is_docker_container:{is_docker_container}.")
|
|
|
47 |
if not is_docker_container:
|
48 |
import webbrowser
|
49 |
webbrowser.open_new('http://127.0.0.1:3000/')
|
50 |
-
app.run(host=
|
|
|
2 |
import os
|
3 |
import webbrowser
|
4 |
|
5 |
+
from aip_trainer import app_logger, log_level
|
6 |
from flask import Flask, render_template, request
|
7 |
from flask_cors import CORS
|
8 |
|
|
|
44 |
if __name__ == "__main__":
|
45 |
is_docker_container = os.getenv("IS_DOCKER_CONTAINER", "").lower() == "yes"
|
46 |
app_logger.info(f"is_docker_container:{is_docker_container}.")
|
47 |
+
hostname = "127.0.0.1" if is_docker_container else "0.0.0.0"
|
48 |
if not is_docker_container:
|
49 |
import webbrowser
|
50 |
webbrowser.open_new('http://127.0.0.1:3000/')
|
51 |
+
app.run(host=hostname, port=3000, debug=log_level=="DEBUG")
|