Using Pyramid framework a minimal standalone (i.e. not using external WEB server) WEB application can be created as follows:
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello World!')
if __name__ == '__main__':
with Configurator() as config:
config.add_route('hello', '/')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 1234, app)
server.serve_forever()
How to achieve this with Django framework?
As my comment says, Django is not meant for this. However, in the interest of curiosity, this is approximately the smallest two-route Django app-project-amalgam I can think of:
You can paste that into a file and run it with e.g.
python minimal_django.py, then navigate to http://127.0.0.1:8000/ or http://127.0.0.1:8000/honk. (There is no database, no static file serving, no auto-reload, nothing. Just a hello and a honk.)But again, Django is not meant for this sort of stuff! Don't do this at home!