Spaces:
Runtime error
Runtime error
taskswithcode
commited on
Commit
•
92791b4
1
Parent(s):
b975e18
Fix
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import json
|
|
8 |
from twc_embeddings import HFModel,SimCSEModel,SGPTModel,CausalLMModel,SGPTQnAModel
|
9 |
import torch
|
10 |
import requests
|
|
|
11 |
|
12 |
|
13 |
MAX_INPUT = 100
|
@@ -34,10 +35,12 @@ INFO_URL = "http://www.taskswithcode.com/stats/"
|
|
34 |
def get_views(action):
|
35 |
print("in get views",action)
|
36 |
ret_val = 0
|
|
|
|
|
37 |
if ("view_count" not in st.session_state):
|
38 |
try:
|
39 |
print("inside get views")
|
40 |
-
app_info = {'name': APP_NAME,"action":action}
|
41 |
res = requests.post(INFO_URL, json = app_info).json()
|
42 |
print(res)
|
43 |
data = res["count"]
|
@@ -48,7 +51,7 @@ def get_views(action):
|
|
48 |
else:
|
49 |
ret_val = st.session_state["view_count"]
|
50 |
if (action != "init"):
|
51 |
-
app_info = {'name': APP_NAME,"action":action}
|
52 |
res = requests.post(INFO_URL, json = app_info).json()
|
53 |
return "{:,}".format(ret_val)
|
54 |
|
|
|
8 |
from twc_embeddings import HFModel,SimCSEModel,SGPTModel,CausalLMModel,SGPTQnAModel
|
9 |
import torch
|
10 |
import requests
|
11 |
+
import socket
|
12 |
|
13 |
|
14 |
MAX_INPUT = 100
|
|
|
35 |
def get_views(action):
|
36 |
print("in get views",action)
|
37 |
ret_val = 0
|
38 |
+
hostname = socket.gethostname()
|
39 |
+
ip_address = socket.gethostbyname(hostname)
|
40 |
if ("view_count" not in st.session_state):
|
41 |
try:
|
42 |
print("inside get views")
|
43 |
+
app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
|
44 |
res = requests.post(INFO_URL, json = app_info).json()
|
45 |
print(res)
|
46 |
data = res["count"]
|
|
|
51 |
else:
|
52 |
ret_val = st.session_state["view_count"]
|
53 |
if (action != "init"):
|
54 |
+
app_info = {'name': APP_NAME,"action":action,"host":hostname,"ip":ip_address}
|
55 |
res = requests.post(INFO_URL, json = app_info).json()
|
56 |
return "{:,}".format(ret_val)
|
57 |
|