我正在尝试将我的脚本加载到位于我网站根目录的JSON文件中:
import matplotlib.pyplot as plt
import numpy as np
def make_pie(sizes, text,colors,labels, radius=1):
col = [[i/255 for i in c] for c in colors]
plt.axis('equal')
width = 0.35
kwargs = dict(colors=col, startangle=180)
outside, _ = plt.pie(sizes, radius=radius, pctdistance=1-width/2,labels=labels,**kwargs)
plt.setp( outside, width=width, edgecolor='white')
kwargs = dict(size=20, fontweight='bold', va='center')
plt.text(0, 0, text, ha='center', **kwargs)
# Group colors
c1 = (226, 33, 7)
c2 = (60, 121, 189)
# Subgroup colors
d1 = (226, 33, 7)
d2 = (60, 121, 189)
d3 = (25, 25, 25)
make_pie([100, 80, 90], "", [d1, d3, d2], ['M', 'N', 'F'], radius=1.2)
make_pie([180, 90], "", [c1, c2], ['M', 'F'], radius=1)
plt.show()
但是,在加载网站时,我收到以下错误:
$.getJSON( "slides.json", function(json) {
var slides = json;
console.log(slides);
}
所以我尝试冲浪到http://mywebsite/slides.json,并且还获得了404.所以我尝试将我的文件扩展名更改为slides.txt,这对于冲浪以及脚本阅读来说都很好。< / p>
有人可以解释为什么我的IIS不会像文本文件那样分发JSON文件吗?
谢谢:)
答案 0 :(得分:1)
不幸的是,默认情况下,IIS不提供JSON服务。请尝试以下步骤:
- 打开IIS管理器
- 右键点击with my_table(id, deviceId, data, createdAt) as (
values
(1, 1, '{}', '2017-05-24'::date),
(2, 1, '{}', '2017-05-25'),
(3, 2, '{}', '2017-05-24'),
(4, 3, '{}', '2017-05-25'),
(5, 1, '{}', '2017-05-01'),
(6, 1, '{}', '2017-05-29')
)
select
case when d = lag(d) over (order by d, deviceid) then null else d::date end as days,
deviceid, data, id
from generate_series('2017-05-24', '2017-05-27', '1d'::interval) d
join my_table on d = createdat
order by d, deviceid;
days | deviceid | data | id
------------+----------+------+----
2017-05-24 | 1 | {} | 1
| 2 | {} | 3
2017-05-25 | 1 | {} | 2
| 3 | {} | 4
(4 rows)
,然后选择MIME
- 添加新操作(右上角有open feature
)
- 为扩展名输入Add...
,为MIME类型输入JSON
。
希望这有帮助!