This commit is contained in:
Ali Abid 2020-07-08 11:17:46 -07:00
commit ae62152ce3
5 changed files with 16 additions and 14 deletions

View File

@ -14,7 +14,7 @@ from gradio.tunneling import create_tunnel
import urllib.request
from shutil import copyfile
import requests
import os
import sys
INITIAL_PORT_VALUE = (
@ -117,7 +117,6 @@ def get_first_available_port(initial, final):
def serve_files_in_background(interface, port, directory_to_serve=None, server_name=LOCALHOST_NAME):
class HTTPHandler(SimpleHTTPRequestHandler):
"""This handler uses server.base_path instead of always using os.getcwd()"""
def _set_headers(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
@ -134,7 +133,6 @@ def serve_files_in_background(interface, port, directory_to_serve=None, server_n
def do_POST(self):
# Read body of the request.
if self.path == "/api/predict/":
# Make the prediction.
self._set_headers()
@ -198,12 +196,13 @@ def serve_files_in_background(interface, port, directory_to_serve=None, server_n
# Now loop forever
def serve_forever():
# try:
while True:
# sys.stdout.flush()
httpd.serve_forever()
# except (KeyboardInterrupt, OSError):
# httpd.server_close()
try:
while True:
sys.stdout.flush()
httpd.serve_forever()
except (KeyboardInterrupt, OSError):
httpd.shutdown()
httpd.server_close()
thread = threading.Thread(target=serve_forever, daemon=False)
thread.start()
@ -215,13 +214,11 @@ def start_simple_server(interface, directory_to_serve=None, server_name=None):
port = get_first_available_port(
INITIAL_PORT_VALUE, INITIAL_PORT_VALUE + TRY_NUM_PORTS
)
httpd = serve_files_in_background(
interface, port, directory_to_serve, server_name)
httpd = serve_files_in_background(interface, port, directory_to_serve, server_name)
return port, httpd
def close_server(server):
server.shutdown()
server.server_close()

BIN
dist/gradio-0.9.9.2-py3-none-any.whl vendored Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: gradio
Version: 0.9.9.1
Version: 0.9.9.2
Summary: Python library for easily interacting with trained machine learning models
Home-page: https://github.com/gradio-app/gradio-UI
Author: Abubakar Abid

View File

@ -4,3 +4,7 @@ paramiko
scipy
IPython
scikit-image
<<<<<<< HEAD
=======
analytics-python
>>>>>>> 64fd79682b1939bca6d2efe2556fc7a7b43b1d9d

View File

@ -5,7 +5,7 @@ except ImportError:
setup(
name='gradio',
version='0.9.9.1',
version='0.9.9.2',
include_package_data=True,
description='Python library for easily interacting with trained machine learning models',
author='Abubakar Abid',
@ -20,5 +20,6 @@ setup(
'scipy',
'IPython',
'scikit-image',
'analytics-python',
],
)