So i'm making a program that runs a flask server an while the flask server runs, connects to localhost.run with ssh. My problem is that if you ssh localhost.run, it does not only return the forwarded url but also a big text with the connection id and other things that i don't need because i only need the url. Here is my code:
import requests, os
from flask import Flask, Response
from multiprocessing import Process
import subprocess
app = Flask(__name__)
# define route for main page
@app.route('/')
def index():
return Response("<h1>123</h1>")
server = Process(target=app.run)
try:
server.start()
print("Starting ssh")
opt = subprocess.run("ssh -R 80:localhost:5000 [email protected]")
print(opt)
except Exception as e:
print("ERR")
print(e)
I tried using re.findall, grep but it did not work, it always returned the full text.