'Flask is not providing a URL

I am a new programmer and I am trying to connect my bot to flask to create a URL for discord. when I run it, it doesn't do it. Am I missing a line here because it is not coming up with an error but it will not run either.

from threading import Thread

app = Flask ('__code__')

@app.route('/')
def home():
  return "Hello. I am alive!"
  app.run(host='0.0.0.0',port=5000)


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

if __name__ == '__code__':
  app.run()```

Can someone point me in the right direction? I normally work on python 3. 

Thank you 


Solution 1:[1]

Try running the app when checking the name of your code, not in home() function:

from flask import Flask
from threading import Thread

app = Flask ('__code__')

@app.route('/')
def home():
  return "Hello. I am alive!"

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

if __name__ == '__code__':
  app.run(host='0.0.0.0',port=5000)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cardstdani