Update app.py
Browse files
app.py
CHANGED
|
@@ -37,6 +37,7 @@ types=[
|
|
| 37 |
"A",
|
| 38 |
"B",
|
| 39 |
"C",
|
|
|
|
| 40 |
"R1",
|
| 41 |
]
|
| 42 |
|
|
@@ -132,6 +133,48 @@ def build_space(token,t_name,s_type,m_type=None,r_type=None,d_app=None,d_css=Non
|
|
| 132 |
)
|
| 133 |
os.remove(f"{uid}css.css")
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
elif s_type == "R1":
|
| 137 |
with open("r1.py", "r") as f:
|
|
|
|
| 37 |
"A",
|
| 38 |
"B",
|
| 39 |
"C",
|
| 40 |
+
"D",
|
| 41 |
"R1",
|
| 42 |
]
|
| 43 |
|
|
|
|
| 133 |
)
|
| 134 |
os.remove(f"{uid}css.css")
|
| 135 |
|
| 136 |
+
elif s_type == "D":
|
| 137 |
+
with open("d.py", "r") as f:
|
| 138 |
+
app = f.read()
|
| 139 |
+
app = app.replace("$name2", m_type)
|
| 140 |
+
app = app.replace("$app2", d_app)
|
| 141 |
+
app = app.replace("$css2", d_css)
|
| 142 |
+
with open(f"{uid}ct.py", "w") as f:
|
| 143 |
+
f.write(app)
|
| 144 |
+
api.upload_file(
|
| 145 |
+
path_or_fileobj=f"{uid}ct.py",
|
| 146 |
+
path_in_repo="app.py",
|
| 147 |
+
repo_id=repo_name,
|
| 148 |
+
token=token,
|
| 149 |
+
repo_type="space",
|
| 150 |
+
)
|
| 151 |
+
os.remove(f"{uid}ct.py")
|
| 152 |
+
with open("css.css", "r") as f:
|
| 153 |
+
app = f.read()
|
| 154 |
+
with open(f"{uid}css.css", "w") as f:
|
| 155 |
+
f.write(app)
|
| 156 |
+
api.upload_file(
|
| 157 |
+
path_or_fileobj=f"{uid}css.css",
|
| 158 |
+
path_in_repo="css.css",
|
| 159 |
+
repo_id=repo_name,
|
| 160 |
+
token=token,
|
| 161 |
+
repo_type="space",
|
| 162 |
+
)
|
| 163 |
+
os.remove(f"{uid}css.css")
|
| 164 |
+
with open("readme.bac", "r") as f:
|
| 165 |
+
app = f.read()
|
| 166 |
+
with open(f"{uid}read.txt", "w") as f:
|
| 167 |
+
f.write(app)
|
| 168 |
+
api.upload_file(
|
| 169 |
+
path_or_fileobj=f"{uid}read.txt",
|
| 170 |
+
path_in_repo="readme.md",
|
| 171 |
+
repo_id=repo_name,
|
| 172 |
+
token=token,
|
| 173 |
+
repo_type="space",
|
| 174 |
+
)
|
| 175 |
+
os.remove(f"{uid}read.txt")
|
| 176 |
+
|
| 177 |
+
|
| 178 |
|
| 179 |
elif s_type == "R1":
|
| 180 |
with open("r1.py", "r") as f:
|