fix socketIO connection and find huggingface working space of the app, updated in README
Browse files- README.md +1 -1
- app.py +8 -4
- templates/Home.html +0 -1
- templates/Output.html +11 -1
README.md
CHANGED
|
@@ -9,4 +9,4 @@ pinned: false
|
|
| 9 |
short_description: Trying to move from Gradio to Flask
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
| 9 |
short_description: Trying to move from Gradio to Flask
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Open https://open-access-biodata-mtdnaclassifier-flask.hf.space/ to run the app.
|
app.py
CHANGED
|
@@ -37,14 +37,18 @@ CANCEL_FLAGS = {} # {job_id: bool}
|
|
| 37 |
JOBS = {} # {job_id: {"accs": [...], "started": False}}
|
| 38 |
|
| 39 |
# (optional) no-cache while debugging
|
| 40 |
-
@app.after_request
|
| 41 |
-
def nocache(resp):
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
|
| 45 |
# request log to verify what the proxy is asking for
|
| 46 |
@app.before_request
|
| 47 |
def _log():
|
|
|
|
|
|
|
| 48 |
print("REQ:", flask.request.method, flask.request.path)
|
| 49 |
|
| 50 |
# Home
|
|
|
|
| 37 |
JOBS = {} # {job_id: {"accs": [...], "started": False}}
|
| 38 |
|
| 39 |
# (optional) no-cache while debugging
|
| 40 |
+
# @app.after_request
|
| 41 |
+
# def nocache(resp):
|
| 42 |
+
# resp.headers["Cache-Control"] = "no-store"
|
| 43 |
+
# return resp
|
| 44 |
+
|
| 45 |
+
print(app.url_map)
|
| 46 |
|
| 47 |
# request log to verify what the proxy is asking for
|
| 48 |
@app.before_request
|
| 49 |
def _log():
|
| 50 |
+
if flask.request.path.startswith('/static/') or flask.request.path == '/favicon.ico' or flask.request.path.startswith('/socket.io'):
|
| 51 |
+
return
|
| 52 |
print("REQ:", flask.request.method, flask.request.path)
|
| 53 |
|
| 54 |
# Home
|
templates/Home.html
CHANGED
|
@@ -6,7 +6,6 @@
|
|
| 6 |
<meta name="description" content="">
|
| 7 |
<!-- meta name="generator" content="Nicepage 7.12.8, nicepage.com"-->
|
| 8 |
<title>Home</title>
|
| 9 |
-
<link rel="stylesheet" href="{{ url_for('static', filename='ping.css') }}" /> <!-- remove afterwards along with static/ping.css-->
|
| 10 |
<link rel="stylesheet" href="{{ url_for('static', filename='nicepage.css') }}">
|
| 11 |
<link rel="stylesheet" href="{{ url_for('static', filename='Home.css') }}">
|
| 12 |
<link id="u-page-google-font" rel="stylesheet" href="https://fonts.googleapis.com/css2?display=swap&family=Roboto:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&family=Lobster:wght@400&family=Roboto+Slab:wght@100;200;300;400;500;600;700;800;900">
|
|
|
|
| 6 |
<meta name="description" content="">
|
| 7 |
<!-- meta name="generator" content="Nicepage 7.12.8, nicepage.com"-->
|
| 8 |
<title>Home</title>
|
|
|
|
| 9 |
<link rel="stylesheet" href="{{ url_for('static', filename='nicepage.css') }}">
|
| 10 |
<link rel="stylesheet" href="{{ url_for('static', filename='Home.css') }}">
|
| 11 |
<link id="u-page-google-font" rel="stylesheet" href="https://fonts.googleapis.com/css2?display=swap&family=Roboto:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&family=Lobster:wght@400&family=Roboto+Slab:wght@100;200;300;400;500;600;700;800;900">
|
templates/Output.html
CHANGED
|
@@ -248,7 +248,17 @@
|
|
| 248 |
setConnection('connecting', 'Connecting…');
|
| 249 |
|
| 250 |
// Create the socket (v3 client)
|
| 251 |
-
const socket = io({ transports: ['websocket', 'polling'], reconnectionAttempts: 5, timeout: 10000 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
socket.on('connect', () => {
|
| 254 |
setConnection('connected', 'Connected');
|
|
|
|
| 248 |
setConnection('connecting', 'Connecting…');
|
| 249 |
|
| 250 |
// Create the socket (v3 client)
|
| 251 |
+
// const socket = io({ transports: ['websocket', 'polling'], reconnectionAttempts: 5, timeout: 10000 });
|
| 252 |
+
// ✅ replace WITH THIS:
|
| 253 |
+
const qs = window.location.search; // includes ?__sign=...
|
| 254 |
+
const endpoint = qs ? ('/?' + qs.slice(1)) : '/'; // build "/?__sign=..."
|
| 255 |
+
const socket = io(endpoint, {
|
| 256 |
+
path: '/socket.io',
|
| 257 |
+
transports: ['websocket','polling'], // allow fallback, then upgrade
|
| 258 |
+
withCredentials: true,
|
| 259 |
+
reconnectionAttempts: 5,
|
| 260 |
+
timeout: 10000
|
| 261 |
+
});
|
| 262 |
|
| 263 |
socket.on('connect', () => {
|
| 264 |
setConnection('connected', 'Connected');
|