Spaces:
Build error
Build error
David Li
commited on
Commit
·
f198f11
1
Parent(s):
a3bd605
fix: basic alfred dart server
Browse files- .gitignore +6 -0
- CHANGELOG.md +3 -0
- Dockerfile +6 -0
- README.md +4 -0
- analysis_options.yaml +30 -0
- bin/cli.dart +30 -0
- lib/core.dart +3 -0
- pubspec.lock +327 -0
- pubspec.yaml +14 -0
- test/cli_test.dart +8 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Files and directories created by pub.
|
2 |
+
.dart_tool/
|
3 |
+
.packages
|
4 |
+
|
5 |
+
# Conventional directory for build output.
|
6 |
+
build/
|
CHANGELOG.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
## 1.0.0
|
2 |
+
|
3 |
+
- Initial version.
|
Dockerfile
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM dart:2.19.1
|
2 |
+
|
3 |
+
RUN pub get
|
4 |
+
RUN dart compile exe bin/cli.dart
|
5 |
+
RUN chmod +x bin/cli
|
6 |
+
ENTRYPOINT [ "bin/cli" ]
|
README.md
CHANGED
@@ -9,3 +9,7 @@ license: openrail
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
12 |
+
|
13 |
+
|
14 |
+
A sample command-line application with an entrypoint in `bin/`, library code
|
15 |
+
in `lib/`, and example unit test in `test/`.
|
analysis_options.yaml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file configures the static analysis results for your project (errors,
|
2 |
+
# warnings, and lints).
|
3 |
+
#
|
4 |
+
# This enables the 'recommended' set of lints from `package:lints`.
|
5 |
+
# This set helps identify many issues that may lead to problems when running
|
6 |
+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
7 |
+
# style and format.
|
8 |
+
#
|
9 |
+
# If you want a smaller set of lints you can change this to specify
|
10 |
+
# 'package:lints/core.yaml'. These are just the most critical lints
|
11 |
+
# (the recommended set includes the core lints).
|
12 |
+
# The core lints are also what is used by pub.dev for scoring packages.
|
13 |
+
|
14 |
+
include: package:lints/recommended.yaml
|
15 |
+
|
16 |
+
# Uncomment the following section to specify additional rules.
|
17 |
+
|
18 |
+
# linter:
|
19 |
+
# rules:
|
20 |
+
# - camel_case_types
|
21 |
+
|
22 |
+
# analyzer:
|
23 |
+
# exclude:
|
24 |
+
# - path/to/excluded/files/**
|
25 |
+
|
26 |
+
# For more information about the core and recommended set of lints, see
|
27 |
+
# https://dart.dev/go/core-lints
|
28 |
+
|
29 |
+
# For additional information about configuring this file, see
|
30 |
+
# https://dart.dev/guides/language/analysis-options
|
bin/cli.dart
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import 'package:dart_off_server/core.dart' as cli;
|
2 |
+
import 'package:alfred/alfred.dart';
|
3 |
+
import 'dart:io';
|
4 |
+
|
5 |
+
void main(List<String> arguments) async {
|
6 |
+
// get port from arguments
|
7 |
+
final port = int.tryParse(arguments.first) ?? 6565;
|
8 |
+
final app = Alfred();
|
9 |
+
|
10 |
+
app.get('/text', (req, res) => 'Text response');
|
11 |
+
|
12 |
+
app.get('/json', (req, res) => {'json_response': true});
|
13 |
+
|
14 |
+
app.get('/jsonExpressStyle', (req, res) {
|
15 |
+
res.json({'type': 'traditional_json_response'});
|
16 |
+
});
|
17 |
+
|
18 |
+
app.get('/file', (req, res) => File('test/files/image.jpg'));
|
19 |
+
|
20 |
+
app.get('/html', (req, res) {
|
21 |
+
res.headers.contentType = ContentType.html;
|
22 |
+
return '<html><body><h1>Test HTML</h1></body></html>';
|
23 |
+
});
|
24 |
+
app.post('/post-route', (req, res) async {
|
25 |
+
final body = await req.body; //JSON body
|
26 |
+
body != null; //true
|
27 |
+
});
|
28 |
+
|
29 |
+
await app.listen(7860); //Listening on port 6565
|
30 |
+
}
|
lib/core.dart
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
int calculate() {
|
2 |
+
return 6 * 7;
|
3 |
+
}
|
pubspec.lock
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by pub
|
2 |
+
# See https://dart.dev/tools/pub/glossary#lockfile
|
3 |
+
packages:
|
4 |
+
_fe_analyzer_shared:
|
5 |
+
dependency: transitive
|
6 |
+
description:
|
7 |
+
name: _fe_analyzer_shared
|
8 |
+
url: "https://pub.dartlang.org"
|
9 |
+
source: hosted
|
10 |
+
version: "47.0.0"
|
11 |
+
analyzer:
|
12 |
+
dependency: transitive
|
13 |
+
description:
|
14 |
+
name: analyzer
|
15 |
+
url: "https://pub.dartlang.org"
|
16 |
+
source: hosted
|
17 |
+
version: "4.7.0"
|
18 |
+
args:
|
19 |
+
dependency: transitive
|
20 |
+
description:
|
21 |
+
name: args
|
22 |
+
url: "https://pub.dartlang.org"
|
23 |
+
source: hosted
|
24 |
+
version: "2.3.1"
|
25 |
+
async:
|
26 |
+
dependency: transitive
|
27 |
+
description:
|
28 |
+
name: async
|
29 |
+
url: "https://pub.dartlang.org"
|
30 |
+
source: hosted
|
31 |
+
version: "2.9.0"
|
32 |
+
boolean_selector:
|
33 |
+
dependency: transitive
|
34 |
+
description:
|
35 |
+
name: boolean_selector
|
36 |
+
url: "https://pub.dartlang.org"
|
37 |
+
source: hosted
|
38 |
+
version: "2.1.1"
|
39 |
+
collection:
|
40 |
+
dependency: transitive
|
41 |
+
description:
|
42 |
+
name: collection
|
43 |
+
url: "https://pub.dartlang.org"
|
44 |
+
source: hosted
|
45 |
+
version: "1.17.0"
|
46 |
+
convert:
|
47 |
+
dependency: transitive
|
48 |
+
description:
|
49 |
+
name: convert
|
50 |
+
url: "https://pub.dartlang.org"
|
51 |
+
source: hosted
|
52 |
+
version: "3.1.0"
|
53 |
+
coverage:
|
54 |
+
dependency: transitive
|
55 |
+
description:
|
56 |
+
name: coverage
|
57 |
+
url: "https://pub.dartlang.org"
|
58 |
+
source: hosted
|
59 |
+
version: "1.6.2"
|
60 |
+
crypto:
|
61 |
+
dependency: transitive
|
62 |
+
description:
|
63 |
+
name: crypto
|
64 |
+
url: "https://pub.dartlang.org"
|
65 |
+
source: hosted
|
66 |
+
version: "3.0.2"
|
67 |
+
file:
|
68 |
+
dependency: transitive
|
69 |
+
description:
|
70 |
+
name: file
|
71 |
+
url: "https://pub.dartlang.org"
|
72 |
+
source: hosted
|
73 |
+
version: "6.1.4"
|
74 |
+
frontend_server_client:
|
75 |
+
dependency: transitive
|
76 |
+
description:
|
77 |
+
name: frontend_server_client
|
78 |
+
url: "https://pub.dartlang.org"
|
79 |
+
source: hosted
|
80 |
+
version: "2.1.3"
|
81 |
+
glob:
|
82 |
+
dependency: transitive
|
83 |
+
description:
|
84 |
+
name: glob
|
85 |
+
url: "https://pub.dartlang.org"
|
86 |
+
source: hosted
|
87 |
+
version: "2.1.1"
|
88 |
+
http_multi_server:
|
89 |
+
dependency: transitive
|
90 |
+
description:
|
91 |
+
name: http_multi_server
|
92 |
+
url: "https://pub.dartlang.org"
|
93 |
+
source: hosted
|
94 |
+
version: "3.2.1"
|
95 |
+
http_parser:
|
96 |
+
dependency: transitive
|
97 |
+
description:
|
98 |
+
name: http_parser
|
99 |
+
url: "https://pub.dartlang.org"
|
100 |
+
source: hosted
|
101 |
+
version: "4.0.2"
|
102 |
+
io:
|
103 |
+
dependency: transitive
|
104 |
+
description:
|
105 |
+
name: io
|
106 |
+
url: "https://pub.dartlang.org"
|
107 |
+
source: hosted
|
108 |
+
version: "1.0.4"
|
109 |
+
js:
|
110 |
+
dependency: transitive
|
111 |
+
description:
|
112 |
+
name: js
|
113 |
+
url: "https://pub.dartlang.org"
|
114 |
+
source: hosted
|
115 |
+
version: "0.6.5"
|
116 |
+
lints:
|
117 |
+
dependency: "direct dev"
|
118 |
+
description:
|
119 |
+
name: lints
|
120 |
+
url: "https://pub.dartlang.org"
|
121 |
+
source: hosted
|
122 |
+
version: "2.0.1"
|
123 |
+
logging:
|
124 |
+
dependency: transitive
|
125 |
+
description:
|
126 |
+
name: logging
|
127 |
+
url: "https://pub.dartlang.org"
|
128 |
+
source: hosted
|
129 |
+
version: "1.1.0"
|
130 |
+
matcher:
|
131 |
+
dependency: transitive
|
132 |
+
description:
|
133 |
+
name: matcher
|
134 |
+
url: "https://pub.dartlang.org"
|
135 |
+
source: hosted
|
136 |
+
version: "0.12.12"
|
137 |
+
meta:
|
138 |
+
dependency: transitive
|
139 |
+
description:
|
140 |
+
name: meta
|
141 |
+
url: "https://pub.dartlang.org"
|
142 |
+
source: hosted
|
143 |
+
version: "1.9.0"
|
144 |
+
mime:
|
145 |
+
dependency: transitive
|
146 |
+
description:
|
147 |
+
name: mime
|
148 |
+
url: "https://pub.dartlang.org"
|
149 |
+
source: hosted
|
150 |
+
version: "1.0.3"
|
151 |
+
node_preamble:
|
152 |
+
dependency: transitive
|
153 |
+
description:
|
154 |
+
name: node_preamble
|
155 |
+
url: "https://pub.dartlang.org"
|
156 |
+
source: hosted
|
157 |
+
version: "2.0.1"
|
158 |
+
package_config:
|
159 |
+
dependency: transitive
|
160 |
+
description:
|
161 |
+
name: package_config
|
162 |
+
url: "https://pub.dartlang.org"
|
163 |
+
source: hosted
|
164 |
+
version: "2.1.0"
|
165 |
+
path:
|
166 |
+
dependency: transitive
|
167 |
+
description:
|
168 |
+
name: path
|
169 |
+
url: "https://pub.dartlang.org"
|
170 |
+
source: hosted
|
171 |
+
version: "1.8.3"
|
172 |
+
pool:
|
173 |
+
dependency: transitive
|
174 |
+
description:
|
175 |
+
name: pool
|
176 |
+
url: "https://pub.dartlang.org"
|
177 |
+
source: hosted
|
178 |
+
version: "1.5.1"
|
179 |
+
pub_semver:
|
180 |
+
dependency: transitive
|
181 |
+
description:
|
182 |
+
name: pub_semver
|
183 |
+
url: "https://pub.dartlang.org"
|
184 |
+
source: hosted
|
185 |
+
version: "2.1.3"
|
186 |
+
shelf:
|
187 |
+
dependency: transitive
|
188 |
+
description:
|
189 |
+
name: shelf
|
190 |
+
url: "https://pub.dartlang.org"
|
191 |
+
source: hosted
|
192 |
+
version: "1.4.0"
|
193 |
+
shelf_packages_handler:
|
194 |
+
dependency: transitive
|
195 |
+
description:
|
196 |
+
name: shelf_packages_handler
|
197 |
+
url: "https://pub.dartlang.org"
|
198 |
+
source: hosted
|
199 |
+
version: "3.0.1"
|
200 |
+
shelf_static:
|
201 |
+
dependency: transitive
|
202 |
+
description:
|
203 |
+
name: shelf_static
|
204 |
+
url: "https://pub.dartlang.org"
|
205 |
+
source: hosted
|
206 |
+
version: "1.1.1"
|
207 |
+
shelf_web_socket:
|
208 |
+
dependency: transitive
|
209 |
+
description:
|
210 |
+
name: shelf_web_socket
|
211 |
+
url: "https://pub.dartlang.org"
|
212 |
+
source: hosted
|
213 |
+
version: "1.0.3"
|
214 |
+
source_map_stack_trace:
|
215 |
+
dependency: transitive
|
216 |
+
description:
|
217 |
+
name: source_map_stack_trace
|
218 |
+
url: "https://pub.dartlang.org"
|
219 |
+
source: hosted
|
220 |
+
version: "2.1.1"
|
221 |
+
source_maps:
|
222 |
+
dependency: transitive
|
223 |
+
description:
|
224 |
+
name: source_maps
|
225 |
+
url: "https://pub.dartlang.org"
|
226 |
+
source: hosted
|
227 |
+
version: "0.10.10"
|
228 |
+
source_span:
|
229 |
+
dependency: transitive
|
230 |
+
description:
|
231 |
+
name: source_span
|
232 |
+
url: "https://pub.dartlang.org"
|
233 |
+
source: hosted
|
234 |
+
version: "1.9.1"
|
235 |
+
stack_trace:
|
236 |
+
dependency: transitive
|
237 |
+
description:
|
238 |
+
name: stack_trace
|
239 |
+
url: "https://pub.dartlang.org"
|
240 |
+
source: hosted
|
241 |
+
version: "1.10.0"
|
242 |
+
stream_channel:
|
243 |
+
dependency: transitive
|
244 |
+
description:
|
245 |
+
name: stream_channel
|
246 |
+
url: "https://pub.dartlang.org"
|
247 |
+
source: hosted
|
248 |
+
version: "2.1.1"
|
249 |
+
string_scanner:
|
250 |
+
dependency: transitive
|
251 |
+
description:
|
252 |
+
name: string_scanner
|
253 |
+
url: "https://pub.dartlang.org"
|
254 |
+
source: hosted
|
255 |
+
version: "1.1.1"
|
256 |
+
term_glyph:
|
257 |
+
dependency: transitive
|
258 |
+
description:
|
259 |
+
name: term_glyph
|
260 |
+
url: "https://pub.dartlang.org"
|
261 |
+
source: hosted
|
262 |
+
version: "1.2.1"
|
263 |
+
test:
|
264 |
+
dependency: "direct dev"
|
265 |
+
description:
|
266 |
+
name: test
|
267 |
+
url: "https://pub.dartlang.org"
|
268 |
+
source: hosted
|
269 |
+
version: "1.21.4"
|
270 |
+
test_api:
|
271 |
+
dependency: transitive
|
272 |
+
description:
|
273 |
+
name: test_api
|
274 |
+
url: "https://pub.dartlang.org"
|
275 |
+
source: hosted
|
276 |
+
version: "0.4.12"
|
277 |
+
test_core:
|
278 |
+
dependency: transitive
|
279 |
+
description:
|
280 |
+
name: test_core
|
281 |
+
url: "https://pub.dartlang.org"
|
282 |
+
source: hosted
|
283 |
+
version: "0.4.16"
|
284 |
+
typed_data:
|
285 |
+
dependency: transitive
|
286 |
+
description:
|
287 |
+
name: typed_data
|
288 |
+
url: "https://pub.dartlang.org"
|
289 |
+
source: hosted
|
290 |
+
version: "1.3.1"
|
291 |
+
vm_service:
|
292 |
+
dependency: transitive
|
293 |
+
description:
|
294 |
+
name: vm_service
|
295 |
+
url: "https://pub.dartlang.org"
|
296 |
+
source: hosted
|
297 |
+
version: "9.4.0"
|
298 |
+
watcher:
|
299 |
+
dependency: transitive
|
300 |
+
description:
|
301 |
+
name: watcher
|
302 |
+
url: "https://pub.dartlang.org"
|
303 |
+
source: hosted
|
304 |
+
version: "1.0.2"
|
305 |
+
web_socket_channel:
|
306 |
+
dependency: transitive
|
307 |
+
description:
|
308 |
+
name: web_socket_channel
|
309 |
+
url: "https://pub.dartlang.org"
|
310 |
+
source: hosted
|
311 |
+
version: "2.3.0"
|
312 |
+
webkit_inspection_protocol:
|
313 |
+
dependency: transitive
|
314 |
+
description:
|
315 |
+
name: webkit_inspection_protocol
|
316 |
+
url: "https://pub.dartlang.org"
|
317 |
+
source: hosted
|
318 |
+
version: "1.2.0"
|
319 |
+
yaml:
|
320 |
+
dependency: transitive
|
321 |
+
description:
|
322 |
+
name: yaml
|
323 |
+
url: "https://pub.dartlang.org"
|
324 |
+
source: hosted
|
325 |
+
version: "3.1.1"
|
326 |
+
sdks:
|
327 |
+
dart: ">=2.17.5 <3.0.0"
|
pubspec.yaml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: dart_off_server
|
2 |
+
description: A sample command-line application.
|
3 |
+
version: 1.0.0
|
4 |
+
# homepage: https://www.example.com
|
5 |
+
|
6 |
+
environment:
|
7 |
+
sdk: '>=2.17.5 <3.0.0'
|
8 |
+
|
9 |
+
# dependencies:
|
10 |
+
# path: ^1.8.0
|
11 |
+
|
12 |
+
dev_dependencies:
|
13 |
+
lints: ^2.0.0
|
14 |
+
test: ^1.16.0
|
test/cli_test.dart
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import 'package:cli/cli.dart';
|
2 |
+
import 'package:test/test.dart';
|
3 |
+
|
4 |
+
void main() {
|
5 |
+
test('calculate', () {
|
6 |
+
expect(calculate(), 42);
|
7 |
+
});
|
8 |
+
}
|