Skip to content

Commit 5dad31e

Browse files
update lints
1 parent d87aa3a commit 5dad31e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://dart.dev/guides/libraries/private-files
22
# Created by `dart pub`
33
.dart_tool/
4-
4+
local/
55
.DS_Store

bin/server.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import 'package:shelf/shelf.dart';
33
import 'package:shelf/shelf_io.dart' as io;
44
import 'package:shelf_static/shelf_static.dart';
55

6-
void main() async {
6+
void main(List<String> arguments) async {
77
// Check if index.html exists
8+
String staticSitePath = arguments.isNotEmpty ? arguments[0] : 'build/web';
9+
810
String indexFile = 'index.html';
911
final handler = const Pipeline()
1012
.addMiddleware(logRequests())
1113
.addMiddleware(_corsHeaders) // Add CORS headers middleware
12-
.addHandler(createStaticHandler('build/web', defaultDocument: indexFile));
14+
.addHandler(createStaticHandler(
15+
staticSitePath,
16+
defaultDocument: indexFile,
17+
serveFilesOutsidePath: false,
18+
));
1319

1420
final handler2 = const Pipeline()
1521
.addMiddleware(logRequests())
@@ -19,7 +25,7 @@ void main() async {
1925
final server = await io.serve(handler, InternetAddress.anyIPv4, 4001);
2026
final server2 = await io.serve(handler2, InternetAddress.anyIPv4, 4002);
2127
print(
22-
'Serving static site at http://${server.address.host}:${server.port}/${indexFile}');
28+
'Serving static site at http://${server.address.host}:${server.port}/$indexFile');
2329
print(
2430
'Serving handling requests at http://${server2.address.host}:${server2.port}');
2531
}

pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,4 @@ packages:
426426
source: hosted
427427
version: "3.1.3"
428428
sdks:
429-
dart: ">=3.7.0-0 <4.0.0"
429+
dart: ">=3.8.0-0 <4.0.0"

0 commit comments

Comments
 (0)