Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a982f021
Commit
a982f021
authored
Jul 29, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the option to log to sky_server
parent
d1f0a8d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
sky_server.dart
packages/flutter_tools/bin/sky_server.dart
+20
-5
No files found.
packages/flutter_tools/bin/sky_server.dart
View file @
a982f021
...
...
@@ -4,29 +4,44 @@
import
'dart:io'
;
import
'package:args/args.dart'
;
import
'package:shelf_static/shelf_static.dart'
;
import
'package:shelf/shelf_io.dart'
as
io
;
import
'package:shelf/shelf.dart'
;
const
String
usage
=
'Usage: sky_server PORT'
;
void
printUsage
(
parser
)
{
print
(
'Usage: sky_server [-v] PORT'
);
print
(
parser
.
usage
);
}
main
(
List
<
String
>
argv
)
async
{
if
(
argv
.
length
!=
1
)
{
print
(
usage
);
ArgParser
parser
=
new
ArgParser
();
parser
.
addFlag
(
'help'
,
abbr:
'h'
,
negatable:
false
,
help:
'Display this help message.'
);
parser
.
addFlag
(
'verbose'
,
abbr:
'v'
,
negatable:
false
,
help:
'Log requests to stdout.'
);
ArgResults
args
=
parser
.
parse
(
argv
);
if
(
args
[
'help'
]
||
args
.
rest
.
length
!=
1
)
{
printUsage
(
parser
);
return
;
}
int
port
;
try
{
port
=
int
.
parse
(
arg
v
[
0
]);
port
=
int
.
parse
(
arg
s
.
rest
[
0
]);
}
catch
(
e
)
{
print
(
usage
);
print
Usage
(
parser
);
return
;
}
Handler
handler
=
createStaticHandler
(
Directory
.
current
.
path
,
serveFilesOutsidePath:
true
);
if
(
args
[
'verbose'
])
handler
=
const
Pipeline
().
addMiddleware
(
logRequests
()).
addHandler
(
handler
);
HttpServer
server
;
try
{
server
=
await
io
.
serve
(
handler
,
InternetAddress
.
LOOPBACK_IP_V4
,
port
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment