Alejandro Cremades commited on
Commit
c6564c0
β€’
1 Parent(s): e3fa2d0

Move output files to `static` and activate static file serving

Browse files
.streamlit/config.toml CHANGED
@@ -7,3 +7,6 @@ backgroundColor="#f6f7eb"
7
  secondaryBackgroundColor="#f5edcb"
8
  textColor="#000000"
9
  font="serif"
 
 
 
 
7
  secondaryBackgroundColor="#f5edcb"
8
  textColor="#000000"
9
  font="serif"
10
+
11
+ [server]
12
+ enableStaticServing = true
Middle_School_Card_Search.py CHANGED
@@ -4,7 +4,7 @@ import streamlit_common.footer
4
  import streamlit_common.lib as lib
5
  import streamlit_common.locale
6
 
7
- mslist_path = "output/middleschool_extra_fields.csv"
8
  _ = streamlit_common.locale.get_locale()
9
 
10
  if "number_shown_results" not in st.session_state:
 
4
  import streamlit_common.lib as lib
5
  import streamlit_common.locale
6
 
7
+ mslist_path = "static/middleschool_extra_fields.csv"
8
  _ = streamlit_common.locale.get_locale()
9
 
10
  if "number_shown_results" not in st.session_state:
list_scripts/7_remove_banned_cards.py CHANGED
@@ -52,5 +52,5 @@ middleschool_df = middleschool_df[["oracle_id", "name", "name_ja"]]
52
  middleschool_df = middleschool_df.sort_values(by=["name", "name_ja"])
53
 
54
  # Write a CSV file
55
- middleschool_df.to_csv("output/middleschool.csv")
56
- middleschool_df.to_json("output/middleschool.json")
 
52
  middleschool_df = middleschool_df.sort_values(by=["name", "name_ja"])
53
 
54
  # Write a CSV file
55
+ middleschool_df.to_csv("static/middleschool.csv")
56
+ middleschool_df.to_json("static/middleschool.json")
list_scripts/8_add_other_fields.py CHANGED
@@ -37,7 +37,7 @@ def add_other_fields(row: pd.DataFrame) -> pd.DataFrame:
37
  return row
38
 
39
 
40
- middleschool_df = pd.read_csv("output/middleschool.csv")
41
  with open("data/middleschool.json") as json_data:
42
  cards = json.loads(json_data.read())
43
 
@@ -45,5 +45,5 @@ middleschool_df = middleschool_df.apply(add_other_fields, axis=1)
45
  middleschool_df["power"] = middleschool_df["power"].astype("Int64")
46
  middleschool_df["toughness"] = middleschool_df["toughness"].astype("Int64")
47
 
48
- middleschool_df.to_csv("output/middleschool_extra_fields.csv")
49
- middleschool_df.to_json("output/middleschool_extra_fields.json")
 
37
  return row
38
 
39
 
40
+ middleschool_df = pd.read_csv("static/middleschool.csv")
41
  with open("data/middleschool.json") as json_data:
42
  cards = json.loads(json_data.read())
43
 
 
45
  middleschool_df["power"] = middleschool_df["power"].astype("Int64")
46
  middleschool_df["toughness"] = middleschool_df["toughness"].astype("Int64")
47
 
48
+ middleschool_df.to_csv("static/middleschool_extra_fields.csv")
49
+ middleschool_df.to_json("static/middleschool_extra_fields.json")
middleschool-cardlist.ipynb CHANGED
@@ -21,7 +21,7 @@
21
  "# !cd data\n",
22
  "# !wget \"https://mtgjson.com/api/v5/AllPrintings.json.bz2\"\n",
23
  "# !bunzip2 AllPrintings.json.bz2\n",
24
- "# !cd -\n"
25
  ]
26
  },
27
  {
@@ -135,7 +135,7 @@
135
  "print(middleschool_df.shape[0], \"cards found\")\n",
136
  "print(\"These are the first and last 5 cards\")\n",
137
  "print(middleschool_df.head())\n",
138
- "print(middleschool_df.tail())\n"
139
  ]
140
  },
141
  {
@@ -199,7 +199,7 @@
199
  "print(middleschool_df.loc[middleschool_df[\"name\"].isin(wrongnames)])\n",
200
  "middleschool_df.loc[middleschool_df[\"name\"].isin(wrongnames), \"name_ja\"] = None\n",
201
  "print(\"After:\")\n",
202
- "print(middleschool_df.loc[middleschool_df[\"name\"].isin(wrongnames)])\n"
203
  ]
204
  },
205
  {
@@ -264,14 +264,14 @@
264
  "english_only_cards = middleschool_df[middleschool_df[\"name_ja\"].isnull()]\n",
265
  "name_list = english_only_cards[\"name\"].to_list()\n",
266
  "for idx, name in enumerate(name_list):\n",
267
- " middleschool_df.loc[\n",
268
- " middleschool_df[\"name\"] == name, \"name_ja\"\n",
269
- " ] = find_japanese_name(name)\n",
270
  " # print(middleschool_df.loc[middleschool_df['name'] == name])\n",
271
  " print(\".\", end=\"\")\n",
272
  " if idx % 80 == 79:\n",
273
  " print()\n",
274
- " time.sleep(1)\n"
275
  ]
276
  },
277
  {
@@ -337,7 +337,7 @@
337
  "middleschool_df = pd.concat([middleschool_df, banned_df]).drop_duplicates(keep=False)\n",
338
  "print(\"Cards legal by set and not banned:\", middleschool_df.shape[0])\n",
339
  "middleschool_df = middleschool_df.reset_index(drop=True)\n",
340
- "middleschool_df = middleschool_df[[\"oracle_id\", \"name\", \"name_ja\"]]\n"
341
  ]
342
  },
343
  {
@@ -354,8 +354,8 @@
354
  "metadata": {},
355
  "outputs": [],
356
  "source": [
357
- "middleschool_df.to_csv(\"output/middleschool.csv\")\n",
358
- "middleschool_df.to_json(\"output/middleschool.json\")\n"
359
  ]
360
  },
361
  {
@@ -383,7 +383,7 @@
383
  "name": "python",
384
  "nbconvert_exporter": "python",
385
  "pygments_lexer": "ipython3",
386
- "version": "3.11.4"
387
  },
388
  "orig_nbformat": 4,
389
  "vscode": {
 
21
  "# !cd data\n",
22
  "# !wget \"https://mtgjson.com/api/v5/AllPrintings.json.bz2\"\n",
23
  "# !bunzip2 AllPrintings.json.bz2\n",
24
+ "# !cd -"
25
  ]
26
  },
27
  {
 
135
  "print(middleschool_df.shape[0], \"cards found\")\n",
136
  "print(\"These are the first and last 5 cards\")\n",
137
  "print(middleschool_df.head())\n",
138
+ "print(middleschool_df.tail())"
139
  ]
140
  },
141
  {
 
199
  "print(middleschool_df.loc[middleschool_df[\"name\"].isin(wrongnames)])\n",
200
  "middleschool_df.loc[middleschool_df[\"name\"].isin(wrongnames), \"name_ja\"] = None\n",
201
  "print(\"After:\")\n",
202
+ "print(middleschool_df.loc[middleschool_df[\"name\"].isin(wrongnames)])"
203
  ]
204
  },
205
  {
 
264
  "english_only_cards = middleschool_df[middleschool_df[\"name_ja\"].isnull()]\n",
265
  "name_list = english_only_cards[\"name\"].to_list()\n",
266
  "for idx, name in enumerate(name_list):\n",
267
+ " middleschool_df.loc[middleschool_df[\"name\"] == name, \"name_ja\"] = (\n",
268
+ " find_japanese_name(name)\n",
269
+ " )\n",
270
  " # print(middleschool_df.loc[middleschool_df['name'] == name])\n",
271
  " print(\".\", end=\"\")\n",
272
  " if idx % 80 == 79:\n",
273
  " print()\n",
274
+ " time.sleep(1)"
275
  ]
276
  },
277
  {
 
337
  "middleschool_df = pd.concat([middleschool_df, banned_df]).drop_duplicates(keep=False)\n",
338
  "print(\"Cards legal by set and not banned:\", middleschool_df.shape[0])\n",
339
  "middleschool_df = middleschool_df.reset_index(drop=True)\n",
340
+ "middleschool_df = middleschool_df[[\"oracle_id\", \"name\", \"name_ja\"]]"
341
  ]
342
  },
343
  {
 
354
  "metadata": {},
355
  "outputs": [],
356
  "source": [
357
+ "middleschool_df.to_csv(\"static/middleschool.csv\")\n",
358
+ "middleschool_df.to_json(\"static/middleschool.json\")"
359
  ]
360
  },
361
  {
 
383
  "name": "python",
384
  "nbconvert_exporter": "python",
385
  "pygments_lexer": "ipython3",
386
+ "version": "3.12.3"
387
  },
388
  "orig_nbformat": 4,
389
  "vscode": {
pages/1_Check_Card_List.py CHANGED
@@ -4,7 +4,7 @@ import streamlit_common.footer
4
  import streamlit_common.lib as lib
5
  import streamlit_common.locale
6
 
7
- mslist_path = "output/middleschool.csv"
8
  _ = streamlit_common.locale.get_locale()
9
 
10
  if "lang" not in st.session_state:
 
4
  import streamlit_common.lib as lib
5
  import streamlit_common.locale
6
 
7
+ mslist_path = "static/middleschool.csv"
8
  _ = streamlit_common.locale.get_locale()
9
 
10
  if "lang" not in st.session_state:
{output β†’ static}/middleschool.csv RENAMED
File without changes
{output β†’ static}/middleschool.json RENAMED
File without changes
{output β†’ static}/middleschool_extra_fields.csv RENAMED
File without changes
{output β†’ static}/middleschool_extra_fields.json RENAMED
File without changes