Get Repl URL from python

How do I get the repl url from python code?

Write this code to make webserver and get webserver url
Write this code

from flask import Flask
app = Flask('app')

@app.route('/')
def hello_world():
  return 'Hello, World!'

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

Or the repl that you made and want get that repl url
It looks like this
https://replit.com/@arhanansari2009/NiftyBoilingMegabyte#main.py in your editor and others https://replit.com/@arhanansari2009/NiftyBoilingMegabyte?v=1

Hope it works
If it works mark it as Solution

Proper solution:

REPL_SLUG = os.getenv("REPL_SLUG")
REPL_OWNER = os.getenv("REPL_OWNER")
REPL_URL = f"https://{REPL_SLUG}.{REPL_OWNER}.repl.co"
3 Likes

Don’t write your code like this
Instead write this

```py
write you code here```

That won’t work lol. You have to it like this:

image

1 Like

No? This:
```py
print(“hello world!”)
```
Becomes

print("hello world!")

Note: IIRC adding “py” there just tells the formatter what code it is so it doesn’t have to guess.

1 Like

Wait…No to me or them?

I thought you were saying that doing ```py wouldn’t work, hang on.

1 Like

Nah I meant doing

write you code here```

wouldn’t work.

Test```
Just checking

Hmm. What about

Test ```

Nope. Has to be on a new line.

1 Like

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