mirror of
https://github.com/Priyanshu-hawk/ChatGPT-unofficial-api-selenium.git
synced 2026-06-02 06:03:34 +02:00
fix api_backend
This commit is contained in:
@@ -24,7 +24,6 @@ if __name__ == '__main__':
|
||||
port = 5000
|
||||
try:
|
||||
update_remote_ip_ngrok_mongo(os.getenv("MONGO_DB_NAME"), os.getenv("MONGO_COLLECTION_NAME"),port=5000 , currStatus=1)
|
||||
load_chrome()
|
||||
start_chat_gpt()
|
||||
app.run(debug=False, port=5000)
|
||||
except KeyboardInterrupt as e:
|
||||
|
||||
+1
-1
@@ -44,6 +44,7 @@ def check_guildlines():
|
||||
print("No guidlines found")
|
||||
|
||||
def start_chat_gpt():
|
||||
load_chrome()
|
||||
driver.maximize_window()
|
||||
driver.get("https://chat.openai.com/chat")
|
||||
#if login page is present
|
||||
@@ -116,7 +117,6 @@ def stop_chat_gpt():
|
||||
# chrome_handler.kill_chrome()
|
||||
|
||||
if __name__ == "__main__":
|
||||
load_chrome()
|
||||
start_chat_gpt()
|
||||
|
||||
try:
|
||||
|
||||
+14
-1
@@ -2,9 +2,22 @@ import os
|
||||
import subprocess
|
||||
import time
|
||||
import sys
|
||||
import platform
|
||||
|
||||
def get_chrome_path():
|
||||
os_name = platform.system().lower()
|
||||
if os_name == "darwin":
|
||||
return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
elif os_name == "windows":
|
||||
return "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
|
||||
elif os_name == "linux":
|
||||
return "/usr/bin/google-chrome"
|
||||
else:
|
||||
raise Exception(f"Unsupported OS: {os_name}")
|
||||
|
||||
def start_chrome():
|
||||
subprocess.Popen(['google-chrome','--remote-debugging-port=9222','--user-data-dir=chromedata'],stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
chrome_path = chrome_path = get_chrome_path()
|
||||
subprocess.Popen([f'{chrome_path}','--remote-debugging-port=9222','--user-data-dir=chromedata'],stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
|
||||
def kill_chrome():
|
||||
subprocess.run(['killall','chrome'])
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from api_backend import load_chrome, start_chat_gpt, make_gpt_request, stop_chat_gpt
|
||||
|
||||
load_chrome()
|
||||
start_chat_gpt()
|
||||
a = make_gpt_request("This just a test promt for the prosing")
|
||||
print(a)
|
||||
|
||||
Reference in New Issue
Block a user