Spaces:
Build error
Build error
David Li
commited on
Commit
•
1577403
1
Parent(s):
9a45cd5
fix: update cli
Browse files- .gitignore +2 -0
- Dockerfile +4 -3
- bin/cli.dart +9 -2
.gitignore
CHANGED
@@ -4,3 +4,5 @@
|
|
4 |
|
5 |
# Conventional directory for build output.
|
6 |
build/
|
|
|
|
|
|
4 |
|
5 |
# Conventional directory for build output.
|
6 |
build/
|
7 |
+
|
8 |
+
*.exe
|
Dockerfile
CHANGED
@@ -2,6 +2,7 @@ FROM dart:2.19.1
|
|
2 |
COPY pubspec.yaml pubspec.lock ./
|
3 |
RUN dart pub get
|
4 |
COPY . ./
|
5 |
-
RUN
|
6 |
-
RUN
|
7 |
-
|
|
|
|
2 |
COPY pubspec.yaml pubspec.lock ./
|
3 |
RUN dart pub get
|
4 |
COPY . ./
|
5 |
+
RUN dart compile exe bin/cli.dart
|
6 |
+
RUN mv bin/cli.exe cli.exe
|
7 |
+
RUN chmod +x cli.exe
|
8 |
+
ENTRYPOINT [ "./cli.exe" ]
|
bin/cli.dart
CHANGED
@@ -4,9 +4,16 @@ import 'dart:io';
|
|
4 |
|
5 |
void main(List<String> arguments) async {
|
6 |
// get port from arguments
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
final app = Alfred();
|
9 |
|
|
|
|
|
10 |
app.get('/text', (req, res) => 'Text response');
|
11 |
|
12 |
app.get('/json', (req, res) => {'json_response': true});
|
@@ -26,5 +33,5 @@ void main(List<String> arguments) async {
|
|
26 |
body != null; //true
|
27 |
});
|
28 |
|
29 |
-
await app.listen(
|
30 |
}
|
|
|
4 |
|
5 |
void main(List<String> arguments) async {
|
6 |
// get port from arguments
|
7 |
+
var port = 7860;
|
8 |
+
if (arguments.isEmpty) {
|
9 |
+
print('Please provide a port number');
|
10 |
+
} else {
|
11 |
+
port = int.tryParse(arguments.first) ?? 6565;
|
12 |
+
}
|
13 |
final app = Alfred();
|
14 |
|
15 |
+
// print line
|
16 |
+
print('Starting up server: on port $port');
|
17 |
app.get('/text', (req, res) => 'Text response');
|
18 |
|
19 |
app.get('/json', (req, res) => {'json_response': true});
|
|
|
33 |
body != null; //true
|
34 |
});
|
35 |
|
36 |
+
await app.listen(port); //Listening on port 6565
|
37 |
}
|