Skip to content

Instantly share code, notes, and snippets.

@yakky
Last active March 16, 2018 09:36
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakky/2379f914b4eba97ae134fb3f7eb20aac to your computer and use it in GitHub Desktop.
Save yakky/2379f914b4eba97ae134fb3f7eb20aac to your computer and use it in GitHub Desktop.
Micro hello world Python Web Framework Royal Rumble @PyCon 7
import django
DEBUG, ROOT_URLCONF, DATABASES, SECRET_KEY = 1, 'pico', {'default': {}}, 'p'
urlpatterns = [django.conf.urls.url(r'^(?P<name>\w+)?$', lambda request,
name: django.http.HttpResponse('hello %s!' % (name or 'world')))]
@yakky
Copy link
Author

yakky commented Apr 16, 2016

You can run this using django-admin runserver --settings=pico and ejoy a django "hello world!"

@carloratm
Copy link

s/ejoy/enjoy/

and now I am a contributor to the weirdest Django project ever \o/

@jefftriplett
Copy link

This is great. You can cut it down to 250 characters if you just import django instead:

import django
DEBUG, ROOT_URLCONF, DATABASES, SECRET_KEY = 1, 'pico', {'default': {}}, 'p'
urlpatterns = [django.conf.urls.url(r'^(?P<name>\w+)?$', lambda request, name: django.http.HttpResponse(
    'hello {name}!'.format(name=(name or 'world'))))]

@yakky
Copy link
Author

yakky commented Nov 25, 2017

Update to your suggestion (edited a bit to fit 80 chars lines which was one of the constraints)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment