Home > Back-end >  TypeError: 'module' object is not callable py 3
TypeError: 'module' object is not callable py 3

Time:11-12

I'm trying to keep my discord bot online on replit. I made a new file called

keep_alive.py

Below is the code I input

import flask
import _thread

app = flask.Flask('Keep Alive')

@app.route('/')
def home():
    return "I'm alive"

def run():
  app.run(host='0.0.0.0',port=8080)

def keep_alive():
    t = _thread(target=run)
    t.start()

I'm not sure what I need to correct.

CodePudding user response:

Replace

import _thread
#and
t = _thread(target=run)

with

from threading import Thread
#and
server = Thread(target=run)

The error is because you are trying to call the module itself.

  • Related