Spaces:
Sleeping
Sleeping
| from flask import Flask, request, redirect, Response | |
| import requests | |
| SITE_NAME ="http://127.0.0.1:8080/" | |
| app = Flask(__name__) | |
| def proxy(): | |
| global SITE_NAME | |
| if request.method=='GET': | |
| url = request.args.get('url') | |
| forward = f'{SITE_NAME}?url={url}' | |
| print(forward) | |
| resp = requests.get(forward) | |
| excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection'] | |
| headers = [(name, value) for (name, value) in resp.raw.headers.items() if name.lower() not in excluded_headers] | |
| response = Response(resp.content, resp.status_code, headers) | |
| return response | |
| def base(): | |
| return """ | |
| <html> | |
| <head> | |
| <title>Netron</title> | |
| <script type="text/javascript"> | |
| function setFile() { | |
| console.log("setFile"); | |
| var url = document.getElementById('url').value; | |
| var iframe = document.getElementById('netron'); | |
| iframe.src = 'http://localhost:7860/?url=' + url; | |
| } | |
| </script> | |
| </head> | |
| <body style="padding: 0; margin: 0; display: flex; flex-direction: column; align-items: center;"> | |
| <input type="text" id="url" value="https://huggingface.co/brianronan/chessbot-test/resolve/main/chessbot.pb" style="width: 100%; height: 30px;"/> | |
| <button type="submit" style="width: 100%; height: 30px;" onClick="setFile">Load</button> | |
| <iframe id="netron" src="http://localhost:7860/?url=https://huggingface.co/brianronan/chessbot-test/resolve/main/chessbot.pb" style="width: 100%; height: 100%; border: none;"/> | |
| </body> | |
| </html> | |
| """ | |