-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from trishume/dlang
Dlang
- Loading branch information
Showing
11 changed files
with
255 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.tern-port | ||
server | ||
nimcache | ||
data | ||
lib/graph | ||
jester | ||
.dub | ||
docs.json | ||
__dummy.html | ||
*.o | ||
*.obj | ||
ratewithscience | ||
__test__library__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "ratewithscience", | ||
"description": "The backend for http://ratewith.science/", | ||
"copyright": "Copyright © 2016, Tristan Hume", | ||
"authors": ["Tristan Hume"], | ||
"libs": ["sqlite3"], | ||
"lflags": ["-L/usr/local/Cellar/sqlite/3.8.10.2/lib/"], | ||
"dependencies": { | ||
"d2sqlite3": "~>0.9.0", | ||
"dunit": "~>1.0.10", | ||
"gfm:core": "~>3.0.11", | ||
"vibe-d": "~>0.7.26" | ||
}, | ||
"versions": ["VibeDefaultMain"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
"libevent": "2.0.1+2.0.16", | ||
"libev": "5.0.0+4.04", | ||
"openssl": "1.1.4+1.0.1g", | ||
"memutils": "0.4.4", | ||
"vibe-d": "0.7.26", | ||
"d2sqlite3": "0.9.0", | ||
"gfm": "3.0.11", | ||
"libasync": "0.7.5", | ||
"dunit": "1.0.12" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import std.stdio, std.datetime; | ||
import vibe.d; | ||
import graph; | ||
|
||
Graph wikiGraph; | ||
TaskMutex mtx; | ||
|
||
@path("/api") | ||
interface Api { | ||
@path("findscale") | ||
graph.Path getFindScale(string start, string stop); | ||
} | ||
|
||
class ApiImpl : Api { | ||
override: | ||
graph.Path getFindScale(string start, string stop) { | ||
StopWatch sw = StopWatch(AutoStart.yes); | ||
writeln("Pathing from ", start, " to ", stop); | ||
mtx.lock(); | ||
auto res = wikiGraph.rateWithScience(start, stop); | ||
mtx.unlock(); | ||
sw.stop(); | ||
writeln("Done pathing with result", res, " it took ", sw.peek().msecs, "ms"); | ||
return res; | ||
} | ||
} | ||
|
||
shared static this() { | ||
wikiGraph = new Graph("data"); | ||
mtx = new TaskMutex; | ||
|
||
auto router = new URLRouter; | ||
router.registerRestInterface(new ApiImpl()); | ||
router.get("*", serveStaticFiles("./public/")); | ||
|
||
auto settings = new HTTPServerSettings; | ||
settings.port = 5000; | ||
listenHTTP(settings, router); | ||
} |
Oops, something went wrong.