How to keep replit flask project/url always active ASAP HELP NEEDED

Hey there!
I am trying to keep a flask project always active so that when i request the output text it wont say Internal Server Error. Maybe the Internal Server Error is another issue so plz help ASAP!

btw my url is: https://gpt4free.muskbot.repl.co/chat and the python program i made to get the info is:

query = input("Enter chat query")
url = 'https://gpt4free.muskbot.repl.co/chat'
params = {'query': query}
response = requests.get(url, params=params)
print(response.text)

for anyone who wants to help, Repl link is https://replit.com/@muskbot/gpt4free

3 Likes

The problem with your code is the formatting. Here’s the fixed code:

from flask import Flask, request
import g4f

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello from Flask!'

@app.route('/chat', methods=['GET'])
def chat():
  # Get parameters from the request URL
  query_message = request.args.get('query', '')
  # Using ChatCompletion for chat models
  response = g4f.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": query_message}],
    stream=True,
  )
  # Iterate over the response and send each message as part of the response
  result = ''.join(message for message in response)

  return f'{result}'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=81)
1 Like

what was the problem (spefics)


EDIT: Thanks yall for your help but i fixed it by publicly publishing the project!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.