Spaces:
Sleeping
Sleeping
File size: 818 Bytes
e23a110 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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() |