Skip to content

Commit 7767f8d

Browse files
committed
doc: update readme to reflect recent error handling changes
1 parent 7327f78 commit 7767f8d

1 file changed

Lines changed: 114 additions & 13 deletions

File tree

readme.md

Lines changed: 114 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ python /path/to/repo/server.py
3232
> 카메라에서 960 x 640 해상도의 MJPEG 영상을 받아와 HTTP 스트림으로 제공.
3333
> HTML의 경우 `<img src="/preview" width="640" height="480">` 등으로 렌더링할 수 있음.
3434
35-
MIME Type: `multipat/x-mixed-replace`
35+
#### Parameter
3636

37-
Parameter: 요청 시 선택적으로 `?timeout=N`을 제공하면 N초 만큼 촬영 후 종료.
37+
요청 시 선택적으로 `?timeout=N`을 제공하면 N초 만큼 촬영 후 종료.
3838

39-
Response Example:
40-
```
39+
#### Response
40+
41+
Status Code | MIME Type | Description
42+
:-:|:-:|:-:
43+
200 | `multipat/x-mixed-replace` | 영상 촬영 시작 성공
44+
45+
```text
4146
HTTP/1.1 200 OK
4247
Content-Type: multipart/x-mixed-replace; boundary=frame
4348
@@ -50,32 +55,121 @@ Content-Type: image/jpeg
5055
5156
<jpeg data here>
5257
```
58+
59+
<br>
60+
61+
Status Code | MIME Type | Description
62+
:-:|:-:|:-:
63+
503 | `text/plain` | 카메라 연결 상태로 인한 촬영 실패.
64+
65+
```
66+
HTTP/1.1 503 SERVICE UNAVAILABLE
67+
Content-Type: text/plain
68+
69+
Capturing preview frames as movie to stdout. Press Ctrl-C to abort.
70+
71+
*** Error ***
72+
An error occurred in the io-library ('Could not claim the USB device"): Could not claim interface 0 (Device or resource busy). Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.
73+
ERROR: Movie capture error... Exiting.
74+
Movie capture finished (0 frames)
75+
```
76+
77+
<br>
78+
79+
Status Code | MIME Type | Description
80+
:-:|:-:|:-:
81+
504 | `text/plain` | 503 이외의 카메라 연결 상태로 인한 촬영 실패
82+
83+
```
84+
HTTP/1.1 504 GATEWAY TIMEOUT
85+
Content-Type: text/plain
86+
87+
*** Error: No camera found. ***
88+
```
89+
90+
<br>
91+
92+
Status Code | MIME Type | Description
93+
:-:|:-:|:-:
94+
500 | `text/plain` | 카메라 서버 프로그램 버그로 인한 오류
95+
96+
```
97+
HTTP/1.1 500 INTERNAL SERVER ERROR
98+
Content-Type: text/html
99+
100+
<!doctype html>
101+
<html lang=en>
102+
<title>500 Internal Server Error</title>
103+
<h1>Internal Server Error</h1>
104+
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
105+
```
106+
53107
<br>
54108

109+
55110
### GET `/capture`
56111

57112
> 카메라에서 2592 x 1728 해상도의 JPEG 사진을 즉시 촬영하여 전송.
58113
> 초점을 맞추고 셔터 소리가 날 때까지 약 2초의 딜레이가 있음.
59114
60-
MIME Type: image/jpeg
115+
#### Response
116+
117+
Status Code | MIME Type | Description
118+
:-:|:-:|:-:
119+
200 | `image/jpeg`| 사진 촬영 성공
61120

62-
Response Example:
63121
```
64122
HTTP/1.1 200 OK
65123
Content-Type: image/jpeg
66124
67125
<jpeg data here>
68126
```
127+
128+
<br>
129+
130+
Status Code | MIME Type | Description
131+
:-:|:-:|:-:
132+
503 | `text/plain` | 카메라 연결 상태로 인한 촬영 실패.
133+
134+
```
135+
HTTP/1.1 503 SERVICE UNAVAILABLE
136+
Content-Type: text/plain
137+
138+
*** Error ***
139+
Could not detect any camera
140+
*** Error (-105: 'Unknown model') ***
141+
```
142+
143+
<br>
144+
145+
Status Code | MIME Type | Description
146+
:-:|:-:|:-:
147+
500 | `text/plain` | 카메라 서버 프로그램 버그로 인한 오류
148+
149+
```
150+
HTTP/1.1 500 INTERNAL SERVER ERROR
151+
Content-Type: text/html
152+
153+
<!doctype html>
154+
<html lang=en>
155+
<title>500 Internal Server Error</title>
156+
<h1>Internal Server Error</h1>
157+
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
158+
```
159+
69160
<br>
70161

71162
### GET `/reset`
72163

73164
> 카메라 상태를 초기화. 카메라 상태로 인한 촬영 오류 시에 유용할 수 있음.
74165
75-
MIME Type: text/html
166+
#### Response
76167

77-
Response Example:
78-
```
168+
Status Code | MIME Type | Description
169+
:-:|:-:|:-:
170+
200 | `text/html`| 카메라 리셋 성공
171+
172+
```text
79173
HTTP/1.1 200 OK
80174
Content-Type: text/html
81175
@@ -85,13 +179,18 @@ Camera has been reset.
85179

86180
### GET `/cmd`
87181

88-
> `gphoto2` 명령행 인자를 `arg` 쿼리파람으로 전송하고, 텍스트로 응답.
182+
> `gphoto2` 명령행 인자를 `arg` 쿼리파람으로 전송하고, stdout 출력을 텍스트로 응답.
183+
184+
#### Parameter
89185

90-
MIME Type: text/plain
186+
요청 시 `?arg=` 뒤에 `gphoto2` 커맨드와 호환되는 1개의 인자를 제공해야 함.
91187

92-
Parameter: 요청 시 `?arg=` 뒤에 `gphoto2` 커맨드와 호환되는 1개의 인자를 제공해야함.
188+
#### Response
189+
190+
Status Code | MIME Type | Description
191+
:-:|:-:|:-:
192+
200 | `text/plain` | gphoto2 명령 실행 완료
93193

94-
Response Example: `/cmd?arg=--auto-detect`
95194
```
96195
HTTP/1.1 200 OK
97196
Content-Type: text/plain
@@ -101,6 +200,8 @@ Model Port
101200
Canon EOS 700D usb:001,007
102201
```
103202

203+
<br>
204+
104205
## Reference
105206
- https://blog.miguelgrinberg.com/post/video-streaming-with-flask
106207
- http://www.gphoto.org/doc/manual/ref-gphoto2-cli.html

0 commit comments

Comments
 (0)