xTHExBEASTx commited on
Commit
58aa998
·
verified ·
1 Parent(s): d7faa2c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import time
4
+ from fastapi import FastAPI
5
+ import uvicorn
6
+
7
+ app = FastAPI()
8
+
9
+ @app.get("/")
10
+ def home():
11
+ return {"status": "Ollama is running", "model": "qwen2.5-coder:7b"}
12
+
13
+ if __name__ == "__main__":
14
+ # Start Ollama in the background
15
+ subprocess.Popen(["ollama", "serve"])
16
+
17
+ # Wait for Ollama to wake up
18
+ time.sleep(5)
19
+
20
+ # Ensure our model is pulled
21
+ subprocess.run(["ollama", "pull", "qwen2.5-coder:7b"])
22
+
23
+ # Start the web server on port 7860 for Hugging Face
24
+ uvicorn.run(app, host="0.0.0.0", port=7860)