Spaces:
Sleeping
Sleeping
Commit ·
e937e73
1
Parent(s): c87585c
commit 00000003
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
|
| 9 |
from huggingface_hub import login
|
| 10 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 11 |
import re
|
|
|
|
| 12 |
|
| 13 |
# ✅ Safe GPU decorator
|
| 14 |
try:
|
|
@@ -172,12 +173,13 @@ with gr.Blocks() as demo:
|
|
| 172 |
|
| 173 |
|
| 174 |
# ---------------- Run both ----------------
|
| 175 |
-
def run_flask():
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
# Start Flask in a background thread
|
| 179 |
-
threading.Thread(target=run_flask, daemon=True).start()
|
| 180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
# Gradio runs on port 7860 in HF Spaces
|
| 182 |
if __name__ == "__main__":
|
| 183 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 9 |
from huggingface_hub import login
|
| 10 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 11 |
import re
|
| 12 |
+
from gradio.routes import mount_gradio_app
|
| 13 |
|
| 14 |
# ✅ Safe GPU decorator
|
| 15 |
try:
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
# ---------------- Run both ----------------
|
| 176 |
+
# def run_flask():
|
| 177 |
+
# app.run(host="0.0.0.0", port=8000)
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
+
# # Start Flask in a background thread
|
| 180 |
+
# threading.Thread(target=run_flask, daemon=True).start()
|
| 181 |
+
app = gr.routes.App.create_app(demo)
|
| 182 |
+
app.mount("/flask", app=app) # Mount Flask under /flask
|
| 183 |
# Gradio runs on port 7860 in HF Spaces
|
| 184 |
if __name__ == "__main__":
|
| 185 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|