For more on
httpie, check out the documentation.
Using Django's WSGIServer in Development
For more on
Using Django’s WSGIServer in Development. In this section, you’ll test Django’s development server using
httpie, a command-line HTTP client for testing requests to your web app from the console.
You can now use
GET docs.python.org to see the response headers and body from the Python documentation’s home page. Before starting the Django development server, you can check your Django project for potential problems.
nohup <command> & executes the command in the background so that you can continue to use your shell.
nohup will redirect standard output and standard error to the file
nohup.out. If it appears that
nohup hangs and leaves you without a cursor, press Enter to get your terminal cursor and shell prompt back.
If you leave the
address:port argument unspecified as seen previously, Django will default to listening on localhost port 8000. You can use the
lsof command to verify more directly that a
python command was invoked to listen on port 8000.
At this point in the course, your app is only listening on localhost, which is the address
127.0.0.1. It’s not yet accessible from a browser, but you can still give it its first visitor by sending a
GET request from the command line within the VM itself.
WSGIServer is nothing more than a Python class defined by Django that implements the Python WSGI protocol. What this means is that it adheres to the Web Server Gateway Interface (WSGI), which is a standard that defines a way for web server software and web applications to interact.
In our example so far, the
django-gunicorn-nginx/ project is the web application. Since you’re serving the app in development, there’s actually no separate web server. Django uses the
simple_server module, which implements a lightweight HTTP server, and fuses the concept of web server versus application server into one command,
Become a Member to join the conversation.