ソースを参照

add plaintext to django

Matthew Flickner 9 年 前
コミット
1e2b414a00

+ 5 - 5
frameworks/Python/django/README.md

@@ -1,11 +1,11 @@
 # [Django](https://www.djangoproject.com/) Benchmarking Test
 
-This is the Django portion of a [benchmarking tests suite](../../) 
+This is the Django portion of a [benchmarking tests suite](../../)
 comparing a variety of web development platforms.
 
-The information below is specific to Django. For further guidance, 
-review the [documentation](http://frameworkbenchmarks.readthedocs.org/en/latest/). 
-Also note that there is additional information provided in 
+The information below is specific to Django. For further guidance,
+review the [documentation](http://frameworkbenchmarks.readthedocs.org/en/latest/).
+Also note that there is additional information provided in
 the [Python README](../).
 
 ## Test Paths & Sources
@@ -15,7 +15,7 @@ the [Python README](../).
 * [Multiple Database Queries](hello/world/views.py): "/dbs?queries=#"*, [World Model](hello/world/models.py)
 * [Fortunes](hello/world/views.py): "/fortunes", [Fortune Model](hello/world/models.py)
 * [Database Updates](hello/world/views.py): "/update?queries=#"*, [World Model](hello/world/models.py)
-* _Plaintext: N/A_
+* [Plaintext](hello/world/views.py): "/plaintext" 
 
 *Replace # with an actual number.
 

+ 2 - 1
frameworks/Python/django/benchmark_config.json

@@ -3,6 +3,7 @@
   "tests": [{
     "default": {
       "setup_file": "setup",
+      "plaintext_url" : "/plaintext",
       "json_url": "/json",
       "db_url": "/db",
       "query_url": "/dbs?queries=",
@@ -25,6 +26,7 @@
     },
     "py3": {
       "setup_file": "setup_py3",
+      "plaintext_url" : "/plaintext",
       "json_url": "/json",
       "db_url": "/db",
       "query_url": "/dbs?queries=",
@@ -47,7 +49,6 @@
     },
     "postgresql": {
       "setup_file": "setup_pg",
-      "json_url": "/json",
       "db_url": "/db",
       "query_url": "/dbs?queries=",
       "fortune_url": "/fortunes",

+ 1 - 0
frameworks/Python/django/hello/hello/urls.py

@@ -14,6 +14,7 @@ urlpatterns = patterns('',
 
     # Uncomment the next line to enable the admin:
     # url(r'^admin/', include(admin.site.urls)),
+    url(r'^plaintext$', 'world.views.plaintext'),
     url(r'^json$', 'world.views.json'),
     url(r'^db$', 'world.views.db'),
     url(r'^dbs$', 'world.views.dbs'),

+ 4 - 2
frameworks/Python/django/hello/world/views.py

@@ -25,6 +25,8 @@ def _get_queries(request):
     queries = 500
   return queries
 
+def plaintext(request):
+  return HttpResponse("Hello, World!", content_type="text/plain")
 
 def json(request):
   response = {
@@ -44,7 +46,7 @@ def dbs(request):
   # one can eliminate dereferences by storing the end dereferenced thing in an identifier
   g = World.objects.get
 
-  # but wait!  there's more!  if we're calling a function over and over with the same parameters, 
+  # but wait!  there's more!  if we're calling a function over and over with the same parameters,
   # we can use even more function magic.
   #r = random.randint
   rp = partial(random.randint, 1, 10000)
@@ -71,7 +73,7 @@ def update(request):
   queries = _get_queries(request)
   g = World.objects.get
   rp = partial(random.randint, 1, 10000)
-  
+
   worlds = []
   for r in [rp() for q in xrange(queries)]:
     w = g(id=r)