From 63df86754d5245ba4de65b56d24d4a2b2ef63623 Mon Sep 17 00:00:00 2001 From: superchargez <87804931+superchargez@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:22:53 +0500 Subject: [PATCH] Update api_like_OAI.py In most offices proxy settings make it impossible to use either internet or accessing a server on network, I made this change to achieve them both. --- examples/server/api_like_OAI.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/server/api_like_OAI.py b/examples/server/api_like_OAI.py index ed19237b0..25e196c6f 100755 --- a/examples/server/api_like_OAI.py +++ b/examples/server/api_like_OAI.py @@ -1,4 +1,18 @@ #!/usr/bin/env python3 +import os +import requests +# Save original proxy settings +original_http_proxy = os.environ.get('http_proxy') +original_https_proxy = os.environ.get('https_proxy') +# Unset the proxies +os.environ['http_proxy'] = '' +os.environ['https_proxy'] = '' +# Reset the proxies to original values after your code +if original_http_proxy is not None: + os.environ['http_proxy'] = original_http_proxy +if original_https_proxy is not None: + os.environ['https_proxy'] = original_https_proxy + import argparse from flask import Flask, jsonify, request, Response import urllib.parse