fileserver
ngtools.local.fileserver
Local fileserver to access local files through HTTP.
This module implements local file servers, that can be used to server local files to a local neuroglancer instance.
Classes:
| Name | Description |
|---|---|
|
A fileserver that serves local files |
|
A fileserver that runs in a background process |
LocalFileServer
A fileserver that serves local files.
All paths should be absolute!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
|
Port number to use |
0
|
ip
|
|
IP address |
'localhost'
|
app
|
|
Application |
None
|
start
|
|
Start straight away. |
True
|
Application
Status
Bases:
Well formatted HTTP status.
Environ
dataclass
Environ(_environ=None, method=None, app=None, path=None, query=None, content_type=None, content_length=None, server_name=None, server_port=None, server_protocol=None, headers=Headers())
WSGI environ, as a dataclass.
method
class-attribute
instance-attribute
The HTTP request method, such as GET or POST. This cannot ever be an empty string, and so is always required.
app
class-attribute
instance-attribute
The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the root" of the server.
path
class-attribute
instance-attribute
The remainder of the request URL's "path", designating the virtual “location” of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash.
query
class-attribute
instance-attribute
The portion of the request URL that follows the "?", if any. May be empty or absent.
content_type
class-attribute
instance-attribute
The contents of any Content-Type fields in the HTTP request. May be empty or absent.
content_length
class-attribute
instance-attribute
The contents of any Content-Length fields in the HTTP request. May be empty or absent.
server_port
class-attribute
instance-attribute
When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used in preference to SERVER_NAME for reconstructing the request URL. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required.
server_protocol
class-attribute
instance-attribute
The version of the protocol the client used to send the request. Typically this will be something like "HTTP/1.0" or "HTTP/1.1" and may be used by the application to determine how to treat any HTTP request headers. (This variable should probably be called REQUEST_PROTOCOL, since it denotes the protocol used in the request, and is not necessarily the protocol that will be used in the server's response. However, for compatibility with CGI we have to keep the existing name.)
headers
class-attribute
instance-attribute
Variables corresponding to the client-supplied HTTP request headers (i.e., variables whose names begin with HTTP_). The presence or absence of these variables should correspond with the presence or absence of the appropriate HTTP header in the request.
request_uri
Return the full request URI, optionally including the query string, using the algorithm found in the “URL Reconstruction” section of PEP 3333. If include_query is false, the query string is not included in the resulting URI.
Handler
Class that handles requests.
StaticFileHandler
Bases:
Serves static files.
ErrorHandler
Bases:
Mock handler for HTTP errors.
MethodNotAllowedHandler
Bases:
Mock handler for error 405.
ServerErrorHandler
Bases:
Mock handler for error 500.
FileNotFoundHandler
Bases:
Mock handler for error 405.