


Django configuration to allow other computers to access the website
In fact, Django comes with a built-in lightweight web server that can be used during site development. We provide this server to allow you to quickly develop your site, which means there is no need to configure a production-level web server (such as Apache) before you are ready to release the product.
But in actual development, instead of one person developing, multiple people need to be able to access this machine. So how do we configure it? Let’s take a look:
1. Create a web project
Run the
django-admin.py startproject pytab
command to create a pytab directory in the current directory.
Note:
If you have a PHP programming background, you may be accustomed to placing your code in the document root directory of the Web server (such as /var/www). In Django, you can't do this. It's not a good idea to put any Python code in the document root of your web server because you run the risk of someone seeing the code directly through the page. This is not a good thing for security. So, place the code in some directory outside of the document root.
2. Run the built-in server
and let it run so that we can access
If you are not already in the mysite directory, go into it now and run the python manage.py runserver command. You will see the following output:
Validating models...
0 errors found
Django version 1.4.3, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000 /
Quit the server with CONTROL-C.
After the above prompt appears, it will be in a waiting state. When an access comes in, some user access information will appear. For example:
[11/Jan/2013 00:47:58] "GET / HTTP/1.1" 200 1957
200 Description The request is successful, 1957 represents the size of the sent data, the unit is B.
Although this development server is great for development, be sure to avoid the idea of using this server in a production-level environment. The server could only reliably handle a single request once at a time and was not subject to any kind of security auditing.
But in actual development, instead of one person developing, multiple people need to be able to access this machine. Django thinks of this problem for us. You can use the runserver command to solve this problem:
1. Change the listening port.
If you want to change the server port, you can pass the port as a command line parameter:
python manage.py runserver 8070
2. You can also change the IP address that the server monitors. This feature is especially useful if you want to share the same development site with other developers. The following command:
python manage.py runserver 0.0.0.0:8000
will cause Django to listen on all network interfaces and IP addresses, thus allowing other computers to connect to the development server.
Now that the server is running, you can now access http://192.168.1.111:8000/ using a web browser on other computers.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

The article discusses popular Python libraries like NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, Django, Flask, and Requests, detailing their uses in scientific computing, data analysis, visualization, machine learning, web development, and H

In Python, how to dynamically create an object through a string and call its methods? This is a common programming requirement, especially if it needs to be configured or run...

Using python in Linux terminal...
