Is there a better way in PYTHON?

I’m importing and using os and requests to read and write virtual ports.

I know that BlynkLib can do it but haven’t quite figured it out. I’ve looked at all the examples but i’m missing something.

I use the following to determine if the app is online. is there a better way?

response = requests.get(blynkdomain + blynktoken + "/isAppConnected")
response = response.text
if response == "true" :
    lasttime = time.time()
    print(time.strftime('%Y%m%d'),     
    time.strftime('%H%M'), "App Connected")

And i use:

os.system("sudo python /home/pi/blynk/blynk_ctrl.py -t " + blynktoken + " -vw 0 0  -vw 1 0 ")

to write to virtual pins. There has to be a better way.

Thanks in advance for the assist.

my mini test has a button set to v1
and a value display set to v2

When i press v1, it outputs to the screen AND puts the timestamp in v2.

import time;
import BlynkLib

BLYNK_AUTH = 'someauthcode'
blynk = BlynkLib.Blynk(BLYNK_AUTH, server="localhost", port=8080)

@blynk.VIRTUAL_WRITE(1)
def v1_write_handler(value):
    ticks = time.time()
    print('Current button value: {}'.format(value[0]))
    print('Current time is: ', ticks)
    blynk.virtual_write(2, ticks)

while True:
    blynk.run()

so, in your program, you would
include the library

import BlynkLib
BLYNK_AUTH = 'someauthcode'
blynk = BlynkLib.Blynk(BLYNK_AUTH)

then your code you posted would look like this.
(i did not check this before posting)

response = requests.get(blynkdomain + blynktoken + "/isAppConnected")
response = response.text
if response == "true" :
    lasttime = time.time()
    print(time.strftime('%Y%m%d'),     
    time.strftime('%H%M'), "App Connected")
    blynk.virtual_write(0, 0)
    blynk.virtual_write(1, 0)