Spaces:
Sleeping
Sleeping
Oscar Wang
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import logging
|
|
| 8 |
import json
|
| 9 |
import psutil
|
| 10 |
from flask import Flask, request, jsonify
|
|
|
|
| 11 |
|
| 12 |
# Configure logging
|
| 13 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -108,8 +109,24 @@ def gradio_interface():
|
|
| 108 |
theme="light" # Specify a theme that works, "light" is an example
|
| 109 |
)
|
| 110 |
|
| 111 |
-
iface
|
| 112 |
|
| 113 |
-
#
|
| 114 |
-
|
| 115 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
import json
|
| 9 |
import psutil
|
| 10 |
from flask import Flask, request, jsonify
|
| 11 |
+
import threading
|
| 12 |
|
| 13 |
# Configure logging
|
| 14 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 109 |
theme="light" # Specify a theme that works, "light" is an example
|
| 110 |
)
|
| 111 |
|
| 112 |
+
return iface
|
| 113 |
|
| 114 |
+
# Function to run Flask app
|
| 115 |
+
def run_flask_app():
|
| 116 |
app.run(host='0.0.0.0', port=7860)
|
| 117 |
+
|
| 118 |
+
# Function to run Gradio interface
|
| 119 |
+
def run_gradio_interface():
|
| 120 |
+
iface = gradio_interface()
|
| 121 |
+
iface.launch(port=7860)
|
| 122 |
+
|
| 123 |
+
# Start Flask and Gradio interfaces in separate threads
|
| 124 |
+
if __name__ == "__main__":
|
| 125 |
+
flask_thread = threading.Thread(target=run_flask_app)
|
| 126 |
+
gradio_thread = threading.Thread(target=run_gradio_interface)
|
| 127 |
+
|
| 128 |
+
flask_thread.start()
|
| 129 |
+
gradio_thread.start()
|
| 130 |
+
|
| 131 |
+
flask_thread.join()
|
| 132 |
+
gradio_thread.join()
|