mirror of
https://github.com/dsward2/macSVG.git
synced 2026-03-02 18:23:58 +01:00
44 lines
1.3 KiB
Objective-C
Executable File
44 lines
1.3 KiB
Objective-C
Executable File
#import "AppDelegate.h"
|
|
#import "HTTPServer.h"
|
|
#import "DDLog.h"
|
|
#import "DDTTYLogger.h"
|
|
|
|
// Log levels: off, error, warn, info, verbose
|
|
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
|
{
|
|
// Configure our logging framework.
|
|
// To keep things simple and fast, we're just going to log to the Xcode console.
|
|
[DDLog addLogger:[DDTTYLogger sharedInstance]];
|
|
|
|
// Initalize our http server
|
|
httpServer = [[HTTPServer alloc] init];
|
|
|
|
// Tell the server to broadcast its presence via Bonjour.
|
|
// This allows browsers such as Safari to automatically discover our service.
|
|
[httpServer setType:@"_http._tcp."];
|
|
|
|
// Normally there's no need to run our server on any specific port.
|
|
// Technologies like Bonjour allow clients to dynamically discover the server's port at runtime.
|
|
// However, for easy testing you may want force a certain port so you can just hit the refresh button.
|
|
// [httpServer setPort:12345];
|
|
|
|
// Serve files from the standard Sites folder
|
|
NSString *docRoot = [@"~/Sites" stringByExpandingTildeInPath];
|
|
DDLogInfo(@"Setting document root: %@", docRoot);
|
|
|
|
[httpServer setDocumentRoot:docRoot];
|
|
|
|
NSError *error = nil;
|
|
if(![httpServer start:&error])
|
|
{
|
|
DDLogError(@"Error starting HTTP Server: %@", error);
|
|
}
|
|
}
|
|
|
|
@end
|