And the structure of the old Ziko python site _python

Source: Internet
Author: User
Tags dba

Early in the morning, computer this thing is used to be called a computer, because its main function is to complete some scientific calculation of things, I remember when I tinker it, is calculated, never thought it could be used to do anything else. Later, another name "computer" gradually received by people, especially when the network developed, computer this thing, if not online, simply do not know what to do. And, now there seems to be a trend to increasingly strengthen the role of the network, while the functionality of the machine, although the hardware is improving, can do things feel less.

No matter how, the network is inseparable from. What do you do after surfing the internet? is to login to XXX website. is not the Internet after the automatic content of the Web into their own computer, but to operate the browser, enter the Web site, open a website page, in order to get what we want to see. So, on the network, must have the website, can let others see. Surfing the Internet--look at the web, this is the occurrence of very high frequency action.

So here's the website. Who made the website? This is nonsense, people do. It's just that the people here may be working for a company, or they may be self-employed.

How does the website do? It's a lot of practice. There are directly written in HTML pages, useful other open source system to do, and so on.

From the beginning, I and all of you reader to see how to do a website with Python.

Wikipedia describes the site as follows:

Web site (English: Website) refers to a collection of related Web pages that are made using tools such as HTML to display specific content on the Internet, according to certain rules. Simply put, a Web site is a communication tool, like a bulletin board, where people can publish information they want to disclose through a website, or use a Web site to provide relevant Web services. People can visit websites through web browsers, get the information they need, or enjoy Internet service. The world's first website was created by Tim Berners-Lee on August 6, 1991.

Website composition

The website is composed of two major parts, one is the server, the other is the program.

Server, is the hardware part. If reader have conditions, can buy their own servers, and then set up their own computer room or hosted to what letter of the room and so on, so have their own server. Of course, a lot of money. If there is not enough money, you can use the method of saving, buy a company to provide the server space, because of the benefits of market economy, people will always think that not everyone can afford a server, nor is it necessary for everyone to buy their own servers. However, if you want to do the site, you do not own the server how to do? So, some people do this business, rental of his own server a part of the space for us poor people, so that the benefit of the poor, as long as there is technology, can be very low price in the Internet to have their own website, the rich (rental server) can also rent rent. It's like renting a house and the landlord's relationship. Of course, the result is that you have to share a server with others, if you rent a separate, the price is expensive.

If, I mean if, if you do the site is not going to put on the internet to let others see at any time (there is this?). Isn't that a white thing? Yes! And many, such as my site has not been done, I will not let others see, at this time can also be their own computer as a server, on their own computer to publish their own website, self appreciation, if necessary, put the next person to the monitor to see the front. Very narcissistic. (in their own computer published website, in fact, can also be seen through the Internet, is a little bit of technology to publish, this is not the focus, this tutorial does not say, need to Google or contact me.) )

Reader and I in the follow-up study, using the server is their own computer. We all like to be narcissistic.

The other part of the server is installed in the software part, usually said the site, more refers to this part. Generally speaking, this part is more complex, because the site is different, and there are many different programs. However, no matter what the site, have to have a look at the interface, this is a Web page, or, as long as there is a Web page, it can be published as a website.

Then there is a relatively simple web site, it's made up of pages, and these pages are just written in HTML (or HTML page editing tools, graphics and text, and you can edit pages), and recall that the Web page I first made was written purely in HTML code. The Web page written in this way is "static" in the jargon. It means that it does not allow users to interact with the site, just let others see it. For example, the spectator hand owes, must search what thing, sorry, the website does not provide this function. This kind of website is less now.

What if you want to increase the interaction function? That will have to deal with the user to submit information to the website of the program. In this way, the site is a lot more, the jargon is often said to be "back end", corresponding to the previous said that the direct display to the audience called "Front-End." What "backend" does is to process the information submitted by the "front-end" user and then give the user a feedback. This is the interaction.

In addition, to save the data on the site, usually use a thing called "database" (this is not necessary, some sites do not have a database, some sites in other ways to store data, such as text, etc.), the database is mainly to store some data, so that the backend and front-end Web site from here to read some data out, Display to reader, or save some of the data submitted by reader for later use.

Database is a professional door in the computer industry, reader is interested in, can in the industry in-depth, the company has a position: DBA, is doing this.

The database, in short, is a cabinet that can be visualized as an electronic file--the place where the electronic files are stored, and the user may run new, intercept, update, delete operations on the data in the file.

Database administrator (English: DB Administrator, referred to as DBA), is the person responsible for managing the database. The database administrator is responsible for running the database on the system, performing backups, enforcing security policies, and maintaining the integrity of the database. Because managing databases is a huge job, the needs of database administrators for each company or organization are very different. A large company may have many database administrators, but a small company may not have a database administrator, and the system administrator manages the database.

The following, generally speaking, the website should be like this:

In order to write a beautiful front-end, generally use CSS and JavaScript, but, in this tutorial, because it is not specifically taught these, so, when it comes to the front-end, do not use CSS and JavaScript, such a bad result is the interface is quite ugly. Please reader endure it.

On the control side, which is the back end, only one language is available: Python. This is the ultimate goal of this tutorial, how to use Python to do Web sites.

Database, I choose MySQL, there are many legends about this database. For example, Wikipedia says:

MySQL (Official pronunciation:/maɪˌɛskjuːˈɛl/"My S-q-l", 1, but also often read English pronunciation:/maɪˈsiːkwəl/"My Sequel") was originally an open source relational database management system, The original developer was the MySQL AB company in Sweden, which was acquired by the Microsystems Micro System (Sun) in 2008. Oracle (Oracle) acquired the Sun-Yang micro-systems company in 2009, and MySQL became Oracle's products.

MySQL has become the most popular open source database in the past because of its high performance, low cost and good reliability, so it is widely used in small and medium Web sites on the Internet. As MySQL matures, it is also being used for more large-scale web sites and applications, such as Wikipedia, Google and Facebook. The very popular open source software portfolio "M" in lamp refers to MySQL.

But Oracle has sharply increased the price of the MySQL business version after being acquired by Oracle, and Oracle no longer supports the development of another free software project, OpenSolaris As a result, the free software community has a hidden concern about whether Oracle will continue to support the MySQL community version (the only free version of MySQL), so that some of the original Open-source software used in MySQL has gradually shifted to other databases. Wikipedia, for example, officially announced in 2013 that it would migrate from MySQL to the MARIADB database.

Anyway, MySQL is still a good database option, enough to support reader to complete a fairly large website.

As for the server space, put it on your own computer.

Starting with the database

Database is the site we want to do a foundation, I do not demonstrate the situation here without the database, because that kind of toy web site, although the teaching is simple, but reader is always a bit dizzy, the distance between the real environment is too big, since learning, learn a bit really.

From now on, enter the process of website construction.

installing MySQL

Your computer is not inherently MySQL, it is essentially a program that needs to be installed on the computer.

If reader is the same as me, using the Ubuntu operating system, you can use the following method (I believe, Ubuntu must be very small, but if reader to become a good programmer, I would recommend this operating system, or other Linux distribution. haha).

The first step is to run the following command on the shell side:

sudo apt-get install mysql-server

In this way, the database is already installed on reader's computer. Of course, of course, you have to configure it.

Step two, configure MySQL

The default MySQL installation after the root user is not password, reader Note that there is a noun "root user", whose username is: root. Run:

$mysql -u root

The reason for using-u root is that I am now a general user (Firehare), and if you do not add-u root, MySQL will assume that Firehare is logged in. Note that I did not enter root user mode here because it is not necessary. In general, the database in MySQL operation, there is no need to enter root user mode, only when the possibility of setting.

After entering MySQL, you will see the beginning of the > symbol, which is the MySQL command operation interface.

The following sets the root user password in MySQL, otherwise, the MySQL service is not safe to say.

mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";

Note that I'm using 123456 as the root password, but the password is unsafe, please use the combination of uppercase and lowercase letters and numbers, and not less than 8 digits.

If you are logged in to the database later, you can use the password you just set up.

In addition to the above installation process, reader if you are using a different operating system, you can search the appropriate installation method on Google, I am not here to demonstrate, because I can only demonstrate the installation process on Ubuntu. However, Google will help you troubleshoot installation problems.

Running MySQL

After installation, you will run it and operate the database to build a website base. I'm going to run the database like this:

qw@qw-Latitude-E4300:~$ mysql -u root -p
Enter password:

Enter the password for the database and then appear:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 373
Server version: 5.5.38-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

When you see this interface, you're already in the data. This data can then be manipulated. For example:

mysql> show databases;
+--------------------+
| Database      |
+--------------------+
| information_schema |
| carstore      |
| cutvideo      |
| itdiffer      |
| mysql       |
| performance_schema |
| phpcms       |
| phpcms2      |
| pushsystem     |
| sipras       |
| test        |
+--------------------+

With this command, the current MySQL database is listed.

In addition to this command line to operate the database, there are many ways to visualize the operation of the database Tools. Here also do not introduce, interested please google. However, I like the command line.

Related Article

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.