aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMilo Casagrande <milo@ubuntu.com>2014-03-24 18:09:30 +0100
committerMilo Casagrande <milo@ubuntu.com>2014-03-24 18:09:30 +0100
commit0bc5c530b2bae8da9ab3bf26f4f14e8dc5047983 (patch)
treead3c1c236491ba0e84d957cf7b3998cfc05a6381 /app
parent9f70c9ac744f50177c325ca75ab73283c7f600ba (diff)
Add external file to handle URLs.
* Add external file where URLs are defined. * Add regex to handle search by id.
Diffstat (limited to 'app')
-rw-r--r--app/server.py12
-rw-r--r--app/urls.py25
2 files changed, 28 insertions, 9 deletions
diff --git a/app/server.py b/app/server.py
index 22238fa..387fa62 100644
--- a/app/server.py
+++ b/app/server.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (C) 2014 Linaro Ltd.
#
# This program is free software: you can redistribute it and/or modify
@@ -18,19 +17,14 @@ import pymongo
import tornado.ioloop
import tornado.web
-from handlers import (
- DefConfHandler,
- JobHandler
-)
+from urls import app_urls
if __name__ == '__main__':
client = pymongo.MongoClient()
application = tornado.web.Application(
- [
- (r'/api/job', JobHandler),
- (r'/api/defconfig', DefConfHandler)
- ], client=client,
+ app_urls,
+ client=client,
)
application.listen(8888)
diff --git a/app/urls.py b/app/urls.py
index e69de29..112bb07 100644
--- a/app/urls.py
+++ b/app/urls.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2014 Linaro Ltd.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+from handlers import (
+ DefConfHandler,
+ JobHandler,
+)
+
+app_urls = [
+ (r'/api/defconfig(?P<sl>/)?(?P<id>.*)', DefConfHandler),
+ (r'/api/job(?P<sl>/)?(?P<id>.*)', JobHandler),
+]