Python repl not waking up for no reason

No matter what I try, repl doesnt wake up. My code seems perfeectly fine, its a python app.

Here is my entire python code:
from flask import Flask, request

app = Flask(name)

@app.route(‘/api/text’, methods=[‘POST’])
def receive_text():
if request.is_json:
text = request.get_json()
else:
text = request.data.decode(‘utf-8’)
print(text)
return ‘Text received’

if name == ‘main’:
app.run(debug=True)

Thats all the code there is…at all.

Can you please format your code like this:

```py
Paste the code here
```

Other than that, can you answer some questions to help:

  • Does running with the run button work?
  • If it does, can you give us the content of the .replit config file

Hi @KailoOwhadi thanks for your post and welcome to the community!

Can you please post a link to your repl?

https://replit.com/@KailoOwhadi/verPythonPt#main.py

Here is the repl link

https://replit.com/@KailoOwhadi/verPythonPt#main.py

Running it works. It starts in the console. But there is no repl config file that I am aware of, unless you mean pyproject.toml?

I can find it with the repl link, but for future reference it is a hidden file that can be shown by clicking the three dots and then “show hidden files”. Everything seems as though it should work, the last thing I could think of is try adding an response to the index page.

1 Like

Thanks,

I think the issue is that you created your code in a Python template, rather than a Flask one. I made a new Flask template, copied in your code, changed one line (see below) and it started a webview immediately.

https://replit.com/@IanAtReplit/SerpentineExemplaryBlogclient

I changed this:

if __name__ == '__main__':
    app.run(debug=True)

to this:

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

Oh yep thats why. I did use python isntead of flask. When trying that rn, Im getting ‘requested url not found on the server’. Do I need to change ‘0.0.0.0’ to something?

1 Like

Glad it’s working for you. The reason you see that error is due to your @app.route as it’s missing the index page

2 Likes

Thanks! That did it then.

Yes you should have the host on 0.0.0.0. This makes sure that Replit knows a server is running and that you’re trying to make a website.

1 Like

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