Use Python django to do web _python

Source: Internet
Author: User

1. Create a Django Project
Use django-admin.py startproject mydjangosite reference here

2, establish the view

From django.http import httpresponsedef Hello (Request): Return HttpResponse ("My first simple Python Django project." ")

3. Modify urls.py


We add a line for Urlpatterns: (R ' ^hello/$ ', hello), which is called Urlpattern, and it's a python tuple. The first element in the tuple is a pattern-matching string (regular expression), and the second element is the view function that the pattern will use.
The beginning letter "R" of the regular expression string. It tells Python that it is an original string and does not need to handle the inside backslash (the escape character). It is a good habit to add "R" before using regular.

4. Run Python manage.py runserver

How to start a development server look here
Http://127.0.0.1:8000/hello

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.