chetanganatra commited on
Commit
528fb02
·
verified ·
1 Parent(s): 9fc5131

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -36,4 +36,32 @@ async def predict(request: Request):
36
  }
37
 
38
  if __name__ == "__main__":
39
- uvicorn.run(app, host="0.0.0.0", port=7860) # Port 7860 is standard for HF Spaces
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  if __name__ == "__main__":
39
+ uvicorn.run(app, host="0.0.0.0", port=7860) # Port 7860 is standard for HF Spaces
40
+
41
+
42
+
43
+ '''
44
+ How to call this via python script:
45
+
46
+ import requests
47
+
48
+ # Replace with your actual space name
49
+ SPACE_NAME = "chetanganatra/test-api"
50
+ API_URL = f"https://{SPACE_NAME.replace('/', '-')}.hf.space/predict"
51
+
52
+ # Prepare the data
53
+ data = {
54
+ "data": ["user123", "What is machine learning?"]
55
+ }
56
+
57
+ # Make the API call
58
+ response = requests.post(API_URL, json=data)
59
+
60
+ if response.status_code == 200:
61
+ result = response.json()
62
+ print(result)
63
+ else:
64
+ print(f"Error: {response.status_code}")
65
+ print(response.text)
66
+
67
+ '''