jonghhhh commited on
Commit
08a05d9
ยท
verified ยท
1 Parent(s): 605f57d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -14
app.py CHANGED
@@ -7,7 +7,7 @@ st.markdown(
7
  """
8
  <style>
9
  .reportview-container .main .block-container{
10
- max-width: 100%;
11
  padding-top: 1rem;
12
  padding-right: 1rem;
13
  padding-left: 1rem;
@@ -22,9 +22,11 @@ st.markdown(
22
  api_key = "Z2FNKPFTMDSTHHR60KS4"
23
  base_url = "https://ecos.bok.or.kr/api/"
24
 
25
- # API ํ˜ธ์ถœ ํ•จ์ˆ˜๋“ค
26
- def get_service_statistics():
27
- url = f"{base_url}StatisticTableList/{api_key}/json/kr/1/1000/"
 
 
28
  response = requests.get(url)
29
  if response.status_code == 200:
30
  return response.json()
@@ -33,8 +35,9 @@ def get_service_statistics():
33
  st.write(response.text)
34
  return None
35
 
36
- def get_statistical_glossary():
37
- url = f"{base_url}StatisticWordList/{api_key}/json/kr/1/1000/"
 
38
  response = requests.get(url)
39
  if response.status_code == 200:
40
  return response.json()
@@ -43,8 +46,9 @@ def get_statistical_glossary():
43
  st.write(response.text)
44
  return None
45
 
46
- def get_statistic_detail_items(stat_code):
47
- url = f"{base_url}StatisticItemList/{api_key}/json/kr/1/1000/{stat_code}"
 
48
  response = requests.get(url)
49
  if response.status_code == 200:
50
  return response.json()
@@ -53,8 +57,9 @@ def get_statistic_detail_items(stat_code):
53
  st.write(response.text)
54
  return None
55
 
56
- def get_statistic_search_conditions(stat_code):
57
- url = f"{base_url}StatisticSearch/{api_key}/json/kr/1/100/{stat_code}"
 
58
  response = requests.get(url)
59
  if response.status_code == 200:
60
  return response.json()
@@ -63,8 +68,9 @@ def get_statistic_search_conditions(stat_code):
63
  st.write(response.text)
64
  return None
65
 
66
- def get_top_100_statistics():
67
- url = f"{base_url}KeyStatisticList/{api_key}/json/kr/1/100/"
 
68
  response = requests.get(url)
69
  if response.status_code == 200:
70
  return response.json()
@@ -73,8 +79,9 @@ def get_top_100_statistics():
73
  st.write(response.text)
74
  return None
75
 
76
- def get_statistical_metadata():
77
- url = f"{base_url}StatisticMeta/{api_key}/json/kr/1/100/"
 
78
  response = requests.get(url)
79
  if response.status_code == 200:
80
  return response.json()
 
7
  """
8
  <style>
9
  .reportview-container .main .block-container{
10
+ max-width: 90%; /* ํ™”๋ฉด ํฌ๊ธฐ๋ฅผ 90%๋กœ ์„ค์ • */
11
  padding-top: 1rem;
12
  padding-right: 1rem;
13
  padding-left: 1rem;
 
22
  api_key = "Z2FNKPFTMDSTHHR60KS4"
23
  base_url = "https://ecos.bok.or.kr/api/"
24
 
25
+ # ์„œ๋น„์Šค ํ†ต๊ณ„ ๋ชฉ๋ก API ํ˜ธ์ถœ ํ•จ์ˆ˜
26
+ def get_service_statistics(start=1, end=10, stat_code=None):
27
+ url = f"{base_url}StatisticTableList/{api_key}/json/kr/{start}/{end}"
28
+ if stat_code:
29
+ url += f"/{stat_code}"
30
  response = requests.get(url)
31
  if response.status_code == 200:
32
  return response.json()
 
35
  st.write(response.text)
36
  return None
37
 
38
+ # ํ†ต๊ณ„์šฉ์–ด์‚ฌ์ „ API ํ˜ธ์ถœ ํ•จ์ˆ˜
39
+ def get_statistical_glossary(term, start=1, end=10):
40
+ url = f"{base_url}StatisticWord/{api_key}/json/kr/{start}/{end}/{term}"
41
  response = requests.get(url)
42
  if response.status_code == 200:
43
  return response.json()
 
46
  st.write(response.text)
47
  return None
48
 
49
+ # ํ†ต๊ณ„ ์„ธ๋ถ€ํ•ญ๋ชฉ ๋ชฉ๋ก API ํ˜ธ์ถœ ํ•จ์ˆ˜
50
+ def get_statistic_detail_items(stat_code, start=1, end=10):
51
+ url = f"{base_url}StatisticItemList/{api_key}/json/kr/{start}/{end}/{stat_code}"
52
  response = requests.get(url)
53
  if response.status_code == 200:
54
  return response.json()
 
57
  st.write(response.text)
58
  return None
59
 
60
+ # ํ†ต๊ณ„ ์กฐํšŒ ์กฐ๊ฑด ์„ค์ • API ํ˜ธ์ถœ ํ•จ์ˆ˜
61
+ def get_statistic_search_conditions(stat_code, period, start_date, end_date, start=1, end=10):
62
+ url = f"{base_url}StatisticSearch/{api_key}/json/kr/{start}/{end}/{stat_code}/{period}/{start_date}/{end_date}"
63
  response = requests.get(url)
64
  if response.status_code == 200:
65
  return response.json()
 
68
  st.write(response.text)
69
  return None
70
 
71
+ # 100๋Œ€ ํ†ต๊ณ„์ง€ํ‘œ API ํ˜ธ์ถœ ํ•จ์ˆ˜
72
+ def get_top_100_statistics(start=1, end=10):
73
+ url = f"{base_url}KeyStatisticList/{api_key}/json/kr/{start}/{end}"
74
  response = requests.get(url)
75
  if response.status_code == 200:
76
  return response.json()
 
79
  st.write(response.text)
80
  return None
81
 
82
+ # ํ†ต๊ณ„ ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค API ํ˜ธ์ถœ ํ•จ์ˆ˜
83
+ def get_statistical_metadata(data_name, start=1, end=10):
84
+ url = f"{base_url}StatisticMeta/{api_key}/json/kr/{start}/{end}/{data_name}"
85
  response = requests.get(url)
86
  if response.status_code == 200:
87
  return response.json()