|
1 | | -# Random-Picture |
2 | | - |
3 | | -随机图片 api |
4 | | - |
5 | | -## 实验地址: |
6 | | - |
7 | | -[http://miku.ueuo.com/](http://miku.ueuo.com/)_(无稳定性保证)_ |
8 | | -[https://random-picture.vercel.app/](https://random-picture.vercel.app/)_(部署到 vercel)_ |
9 | | - |
10 | | -### 注意: |
11 | | - |
12 | | -| 路径 | 说明 | |
13 | | -| --------------- | -------------------------------------- | |
14 | | -| ./url.csv | 务必一行一个 url,不要输入不完整的 url | |
15 | | -| ./api/index.php | 修改 ALLOW_OUTPUT 以开启服务器输出 | |
16 | | - |
17 | | -## 部署到 Vercel |
18 | | - |
19 | | -建议 fork 后,自行修改配置,然后在 Vercel 平台上导入自己的项目 |
20 | | -[](https://vercel.com/import/git?s=https%3A%2F%2Fgithub.com%2FCrazy-White%2FRandom-Picture) |
21 | | - |
22 | | -## 关于 Rewrite |
23 | | - |
24 | | -伪静态是可选的。 |
25 | | -开启伪静态后,将支持以<https://example.net/:id.png>形式访问 |
26 | | -**:id** 即图片 id,如果非数字,则随机跳转。请求会被缓存。 |
27 | | -Apache 和 Vercel 部署都直接支持伪静态。 |
28 | | -Nginx 参照以下配置: |
29 | | - |
30 | | -```nginx |
31 | | -location / { |
32 | | - if (!-e $request_filename) { |
33 | | - rewrite ^(\w)*\.(?:jpg|jpeg|png|gif|bmp|webp)$ /api/index.php?id=$1 last; |
34 | | - } |
35 | | -} |
36 | | -``` |
37 | | - |
38 | | -## Doc |
39 | | - |
40 | | -<section> |
41 | | - <h3><strong>直接调用</strong></h3> |
42 | | - <p>访问./api即可,跳转至图片地址</p> |
43 | | - <p>访问./api/?id=数字,跳转至指定图片</p> |
44 | | - <p>注:api附加参数 api=数字 亦可跳转至指定图片</p> |
45 | | - <p>如:<a href="./api/?type=json&id=3">./api/?type=json&id=3</a></p> |
46 | | - </section> |
47 | | - <section> |
48 | | - <h3><strong>访问<a href="./api/?type=length">./api/?type=length</a></strong></h3> |
49 | | - <p>返回图片总量,即id的最大值</p> |
50 | | - </section> |
51 | | - <section> |
52 | | - <h3><strong>访问<a href="./api/?type=output">./api/?type=output</a></strong></h3> |
53 | | - <p>服务器读取后输出,一般不建议使用,默认禁用</p> |
54 | | - </section> |
55 | | - <section> |
56 | | - <h3><strong>访问<a href="./api/?type=json">./api/?type=json</a></strong></h3> |
57 | | - <p>服务器输出json</p> |
58 | | - <pre class="language-json"> |
59 | | - <code class="language-json"> |
60 | | -{"code":"200","url":"https:\/\/fp1.fghrsh.net\/2019\/07\/15\/c2549aaa63db078834ead6a92fe63b61.jpg"} |
61 | | - </code> |
62 | | -</pre> |
63 | | - </section> |
64 | | - <section> |
65 | | - <h3><strong>访问<a href="./api/?type=JSON">./api/?type=JSON</a></strong></h3> |
66 | | - <p>服务器读取图片信息后输出json,如非需要图片信息不建议使用</p> |
67 | | - <pre class="language-json"> |
68 | | - <code class="language-json"> |
69 | | -{"code":"200","url":"https:\/\/fp1.fghrsh.net\/2019\/07\/15\/c2549aaa63db078834ead6a92fe63b61.jpg","width":"1920","height":"1080","mime":"image\/jpeg","size":"821735"} |
70 | | - </code> |
71 | | -</pre> |
72 | | - </section> |
| 1 | +# Random-Picture |
| 2 | + |
| 3 | +随机图片 api |
| 4 | + |
| 5 | +## 实验地址: |
| 6 | + |
| 7 | +<https://illyasviel.feedia.co/> _(无稳定性保证)_ |
| 8 | +<https://random-picture.vercel.app/> _(部署到 vercel)_ |
| 9 | + |
| 10 | +### 注意: |
| 11 | + |
| 12 | +| 路径 | 说明 | |
| 13 | +| --------------- | ------------------------------------------------------- | |
| 14 | +| ./url.csv | 务必一行一个 url,不要输入不完整的 url | |
| 15 | +| ./api/index.php | ALLOW_OUTPUT 是否允许服务器输出;ERROR_IMG 出错时的图片 | |
| 16 | + |
| 17 | +## 部署到 Vercel |
| 18 | + |
| 19 | +建议 fork 后,自行修改配置,然后在 Vercel 平台上导入自己的项目 |
| 20 | +[](https://vercel.com/import/git?s=https%3A%2F%2Fgithub.com%2FCrazy-White%2FRandom-Picture) |
| 21 | + |
| 22 | +## 关于 Rewrite |
| 23 | + |
| 24 | +伪静态是可选的。 |
| 25 | +开启伪静态后,将支持以<https://example.net/:id.png>形式访问 |
| 26 | +**:id** 即图片 id,如果非数字,则随机跳转。请求会被缓存。 |
| 27 | +Apache 和 Vercel 部署都直接支持伪静态。 |
| 28 | +Nginx 参照以下配置: |
| 29 | + |
| 30 | +```nginx |
| 31 | +location / { |
| 32 | + if (!-e $request_filename) { |
| 33 | + rewrite ^(\w)*\.(?:jpg|jpeg|png|gif|bmp|webp)$ /api/index.php?id=$1 last; |
| 34 | + } |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +## Doc |
| 39 | + |
| 40 | +<section> |
| 41 | + <h3><strong>直接调用</strong></h3> |
| 42 | + <p>访问./api即可,跳转至图片地址</p> |
| 43 | + <p>访问./api/?id=数字,跳转至指定图片</p> |
| 44 | + <p>注:api附加参数 api=数字 亦可跳转至指定图片</p> |
| 45 | + <p>如:<a href="./api/?type=json&id=3">./api/?type=json&id=3</a></p> |
| 46 | + </section> |
| 47 | + <section> |
| 48 | + <h3><strong>访问<a href="./api/?type=length">./api/?type=length</a></strong></h3> |
| 49 | + <p>返回图片总量,即id的最大值</p> |
| 50 | + </section> |
| 51 | + <section> |
| 52 | + <h3><strong>访问<a href="./api/?type=output">./api/?type=output</a></strong></h3> |
| 53 | + <p>服务器读取后输出,一般不建议使用,默认禁用</p> |
| 54 | + </section> |
| 55 | + <section> |
| 56 | + <h3><strong>访问<a href="./api/?type=json">./api/?type=json</a></strong></h3> |
| 57 | + <p>服务器输出json</p> |
| 58 | + <pre class="language-json"> |
| 59 | + <code class="language-json"> |
| 60 | +{"code":"200","url":"https:\/\/fp1.fghrsh.net\/2019\/07\/15\/c2549aaa63db078834ead6a92fe63b61.jpg"} |
| 61 | + </code> |
| 62 | +</pre> |
| 63 | + </section> |
| 64 | + <section> |
| 65 | + <h3><strong>访问<a href="./api/?type=JSON">./api/?type=JSON</a></strong></h3> |
| 66 | + <p>服务器读取图片信息后输出json,如非需要图片信息不建议使用</p> |
| 67 | + <pre class="language-json"> |
| 68 | + <code class="language-json"> |
| 69 | +{"code":"200","url":"https:\/\/fp1.fghrsh.net\/2019\/07\/15\/c2549aaa63db078834ead6a92fe63b61.jpg","width":"1920","height":"1080","mime":"image\/jpeg","size":"821735"} |
| 70 | + </code> |
| 71 | +</pre> |
| 72 | + </section> |
0 commit comments