import os from dotenv import load_dotenv from subprocess import Popen load_dotenv() import mercury print(mercury.__file__) print(os.path.dirname(mercury.__file__)) index_file = os.path.join(os.path.dirname(mercury.__file__), "frontend-dist", "index.html") with open(index_file, "r") as fin: index_content = fin.read() old = """href="/static/""" new = """href="https://hf.space/embed/pplonski/mercury-test/static/""" index_content = index_content.replace(old, new) old = """src="/static/""" new = """src="https://hf.space/embed/pplonski/mercury-test/static/""" index_content = index_content.replace(old, new) #with open(index_file, "w") as fout: # fout.write(index_content) command = ["mercury", "run", f"0.0.0.0:{os.environ.get('PORT', 7860)}"] print(command) worker = Popen(command) worker.wait()