public class SimpleHTTPServer extends Object
Modifier and Type | Field and Description |
---|---|
static Configuration |
freeMarker_configuration |
static boolean |
useIndexHtml |
Constructor and Description |
---|
SimpleHTTPServer(processing.core.PApplet parent)
Creates a HTTPServer listening on port 8000
|
SimpleHTTPServer(processing.core.PApplet parent,
int port)
Creates a SimpleHTTPServer listening on a specified port
|
Modifier and Type | Method and Description |
---|---|
void |
addCallback(String uriPath,
String callbackFunctionName)
add a callback function to the context under the given uri path.
|
void |
createContext(String path,
com.sun.net.httpserver.HttpHandler handler)
Makes SOMETHING available on the server und a sepecific url.
|
processing.core.PApplet |
getParent()
Return the PApplet object that contains the server
|
boolean |
isRunning()
return if the server has been started
|
void |
printAllContexts() |
void |
removeContext(String uriPath)
Remove the contect given under the passed uri path
|
void |
serve(String fileName)
Makes a file available on the server(html,css or js).
|
void |
serve(String path,
String fileName)
Makes a file available on the server(html,css or js)
|
void |
serve(String path,
String fileName,
String callbackFunctionName)
Makes a file available on the server(html,css or js)
|
void |
serveAll(String path)
Serve all files in the data folder, recursively, leaving out hidden
files.
|
void |
serveAll(String path,
boolean recursive,
boolean ignoreHiddenFiles)
Serves all files in the data folder.
|
void |
serveAll(String path,
String directoyName)
Serves all files in the given folder.
|
void |
serveAll(String path,
String directoyName,
boolean recursive,
boolean ignoreHiddenFiles)
Serves all files in the given folder.
|
static void |
setLoggerLevel(Level level)
Sets the level of the Logger.
|
void |
start()
Starts the server
|
void |
stop()
Stop the server
|
public static Configuration freeMarker_configuration
public static boolean useIndexHtml
public SimpleHTTPServer(processing.core.PApplet parent)
parent
- Processing parentpublic SimpleHTTPServer(processing.core.PApplet parent, int port)
parent
- Processing parentport
- port for the serverpublic void start()
public void stop()
public void serve(String fileName)
fileName
- file in the data folder to servepublic void serve(String path, String fileName)
path
- url pathfileName
- file in the data folder to servepublic void serveAll(String path)
path
- the context base-pathpublic void serveAll(String path, boolean recursive, boolean ignoreHiddenFiles)
path
- the context base-pathrecursive
- recursively include subdirectoriesignoreHiddenFiles
- ignore hidden files (starting with . under UNIX)public void serveAll(String path, String directoyName)
path
- the context base-pathdirectoyName
- absolute directory of the files to servepublic void serveAll(String path, String directoyName, boolean recursive, boolean ignoreHiddenFiles)
path
- the context base-pathdirectoyName
- absolute directory of the files to serverecursive
- recursively include subdirectoriesignoreHiddenFiles
- ignore hidden files (starting with . under UNIX)public void serve(String path, String fileName, String callbackFunctionName)
path
- url pathfileName
- file in the data folder to servecallbackFunctionName
- name of the functionpublic void createContext(String path, com.sun.net.httpserver.HttpHandler handler)
path
- urlhandler
- HttpHandler
(http://docs.oracle.com/javase/7/docs/api/javax/xml/ws/spi/
http/HttpHandler.html)public processing.core.PApplet getParent()
public boolean isRunning()
public void removeContext(String uriPath)
uriPath
- the path of the contextpublic void addCallback(String uriPath, String callbackFunctionName)
uriPath
- uri path of the context, which should have the callbackcallbackFunctionName
- name of the callback functionpublic static void setLoggerLevel(Level level)
level
- new level for the loggerpublic void printAllContexts()
Processing library SimpleHTTPServer by Ramin Soleymani. (c) 2016