Linux system constructs Django framework for Web Access

Source: Internet
Author: User

Open Terminal Input Command

django-admin startproject demo   #其中demo是项目名称可以自定义

Open the Terminal input command in the manage.py peer directory to start the project

python3 manage.py runserver

Enter the native IP in the browser 127.0.0.1:8000 Linux system command line input ifconfig can view IP

Show it worked! indicates a successful run

Create an App

python3 manage.py startapp myweb   #myweb是应用名称u

Configure root route, sub-route, and views view

Open the URLs in the demo directory to configure the root route enter the following code to overwrite

 from Import Url,include  from Import  = [        url (r'^', include ('mydemo.urls ' )),]

Create a sub-route under Mydemo

 from Import URL  from Import  = [    url (r'^hello', Views.index),]

Open the Views view overlay code under Mydemo

 from Import Render  from Import HttpResponse # Create your views here. # Define view functions, business logic def Index (Request):     # return a sentence    return HttpResponse ('Hello world!!! ')

Restart Project Python3 manage.py runserver

Access native Ip127.0.0.1/hello in the browser #子路由可以设置路径

Linux system constructs Django framework for Web Access

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.