Spaces:
Paused
Paused
Commit ·
a007d51
1
Parent(s): 2de861b
Cleaning up the interface a bit
Browse files- proxy.py +6 -18
- requirements.txt +2 -1
proxy.py
CHANGED
|
@@ -38,31 +38,19 @@ def redirect_to_API_HOST(path): #NOTE var :path will be unused as all path we n
|
|
| 38 |
response = Response(res.content, res.status_code, headers)
|
| 39 |
return response
|
| 40 |
|
|
|
|
|
|
|
| 41 |
@app.get("/")
|
| 42 |
def chooser():
|
|
|
|
|
|
|
| 43 |
return """
|
| 44 |
<html>
|
| 45 |
<head>
|
| 46 |
<title>Netron</title>
|
| 47 |
-
<script type="text/javascript">
|
| 48 |
-
function setFile() {
|
| 49 |
-
console.log("Query params", window.location.search);
|
| 50 |
-
if (!window.location.search) {
|
| 51 |
-
return;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
const urlParams = new URLSearchParams(window.location.search);
|
| 55 |
-
const url = urlParams.get('url');
|
| 56 |
-
var iframe = document.getElementById('netron');
|
| 57 |
-
iframe.src = '/netron?url=' + url;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
console.log("Top level URL", window.top.location);
|
| 61 |
-
window.onload(setFile());
|
| 62 |
-
</script>
|
| 63 |
</head>
|
| 64 |
<body style="padding: 0; margin: 0; display: flex; flex-direction: row; align-items: center;">
|
| 65 |
-
<iframe id="netron" src="/netron?url=
|
| 66 |
</body>
|
| 67 |
</html>
|
| 68 |
-
"""
|
|
|
|
| 38 |
response = Response(res.content, res.status_code, headers)
|
| 39 |
return response
|
| 40 |
|
| 41 |
+
from huggingface_hub import hf_hub_url
|
| 42 |
+
|
| 43 |
@app.get("/")
|
| 44 |
def chooser():
|
| 45 |
+
file_url = hf_hub_url(request.args.get("repo_id"), request.args.get("filename"))
|
| 46 |
+
|
| 47 |
return """
|
| 48 |
<html>
|
| 49 |
<head>
|
| 50 |
<title>Netron</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
</head>
|
| 52 |
<body style="padding: 0; margin: 0; display: flex; flex-direction: row; align-items: center;">
|
| 53 |
+
<iframe id="netron" src="/netron?url={file_url}" style="width: 100%; height: calc(100% - 30px); border: none;"></iframe>
|
| 54 |
</body>
|
| 55 |
</html>
|
| 56 |
+
""".format(file_url)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
flask
|
| 2 |
netron
|
| 3 |
-
requests
|
|
|
|
|
|
| 1 |
flask
|
| 2 |
netron
|
| 3 |
+
requests
|
| 4 |
+
huggingface_hub
|