add directoryIndex option
This commit is contained in:
parent
ee1b0d7ff7
commit
022657d53a
|
@ -11,9 +11,14 @@ class InAppLocalhostServer {
|
|||
bool _started = false;
|
||||
HttpServer? _server;
|
||||
int _port = 8080;
|
||||
String _directoryIndex = 'index.html';
|
||||
|
||||
InAppLocalhostServer({int port = 8080}) {
|
||||
InAppLocalhostServer({
|
||||
int port = 8080,
|
||||
String directoryIndex = 'index.html',
|
||||
}) {
|
||||
this._port = port;
|
||||
this._directoryIndex = directoryIndex;
|
||||
}
|
||||
|
||||
///Starts the server on `http://localhost:[port]/`.
|
||||
|
@ -46,7 +51,7 @@ class InAppLocalhostServer {
|
|||
|
||||
var path = request.requestedUri.path;
|
||||
path = (path.startsWith('/')) ? path.substring(1) : path;
|
||||
path += (path.endsWith('/')) ? 'index.html' : '';
|
||||
path += (path.endsWith('/')) ? _directoryIndex : '';
|
||||
|
||||
try {
|
||||
body = (await rootBundle.load(path)).buffer.asUint8List();
|
||||
|
|
Loading…
Reference in New Issue