Tried to get it work with the duplicated Questions that got marked on my previous questions serve static files
But I only get this:
Not Found
The requested URL was not found on the server. If you entered the URL
manually please check your spelling and try again.
Here is my code:
app = Flask(__name__, static_url_path='')
@app.route('/WilmaGetLogs/<name>"')
def WilmaGetLogs(name):
path="cat /var/log/messages"
tempStr=''
HOST = name
user = "root"
password = "asdf"
print('Test')
tn = telnetlib.Telnet(HOST, timeout=5)
tn.read_until(b"login: ")
time.sleep(1)
tn.write(user.encode('ascii') + b"\n")
tn.read_until(b'Password: ')
time.sleep(1)
tn.write(password.encode('ascii') + b"\n")
time.sleep(2)
tn.write(path.encode('ascii') + b"\n")
tn.write(b"exit\n")
tempStr=tn.read_all().decode('ascii')
text_file=open("output.txt","w")
text_file.write(tempStr)
text_file.close()
return app.send_static_file("output.txt")
The File output.txt gets created in the directory the .py file is running and my static path is set to '' so it should use the root directory of the program running - or not?
What I want to do is: get the file on the computer as download, where I press the Button to execute WilmaGetLogs - not on the server