Run http.server and do stuff at once, python

146 Views Asked by At

is there any way to figure this out? I want to run a command invisibly and do stuff at once

import os

def run():
    os.system("python -m http.server C:/Showtape/payload/payload.exe 80")
    print("Server running...")
    print("Serving payload..")

What i wanted is, I want the command running invisibly and print the "Server running...", how im gonna do that?

1

There are 1 best solutions below

0
On

Use the http.server module directly in your code instead of shelling out to start a new Python process. You could start the server in a thread, for instance.

This source code in http/server.py is exactly what happens when you run python -m http.server