> Web

bootstrap

1. Quick Start <head> ... <!-- development --> <link rel="stylesheet" href="static/plugins/bootstrap-3.4.1/css/bootstrap.css"> <!-- production --> <link rel="stylesheet" href="static/plugins/bootstrap-3.4.1/css/bootstrap.min.css"> <style> .navbar{ border-radius: 0; } </style> </head> <body> <!-- button --> <input type="button" value="enter" class="btn btn-primary"/> <!-- col-xs --> <div class="col-xs-offset-2 col-xs-2" style="color:red;">1</div> <div class="col-xs-2" style="color:green;">2</div> <!-- col-sm col-md col-lg --> </body>

Continue reading

CSS

1. Intro 1.1 <div style="color:red;"> contents </div> 1.2 <head> <style> .c1{ color: red; } #c2{ color: green; } li{ /* global */ color: pink; } input[type='text']{ border: 1px solid red; } .v1[attr='123']{ ... } .mylist li{ /* children and grandchildren */ color: red; } .mydiv > a{ /* only children */ } </style> </head> ... <div class='c1'>contents</div> <div id='c2'>contents</div> <ul> <li> ccc </li> ... </ul> <input type="text" /> <input type="password" /> 1.

Continue reading

Ajax

1. Intro Ajax can send request without refreshing the webpage. 1.1 Get function clickMe(){ $.ajax({ url: "/user/list", type: "get", data: { name: $("#input1").val(), passwd: $("#input2").val() }, // data: $("#form1").serialize(), dataType: "JSON", success:function(res){ console.log(res.data); } }) } ... <div> <input type="button" value="button" onclick="clickMe();" /> </div> ... Or, we can use JQuery to bind the event of button click. 1.2 Post # views.py from django.shortcuts import render, HttpResponse from django.http import JsonResponse from django.

Continue reading

ORM

1. Install pip install mysqlclient # python<=3.5 pip install pymysql # python>3.5 2. connect # mysite/settings.py ... import pymysql # python>=3.5 pymysql.install_as_MySQLdb() DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'table111', 'USER': 'root', 'PASSWORD': 'Root1234@', 'HOST': 'localhost', 'PORT': 3306, } } ... 3. CRUD # models.py from django.db import models class User(models.Model): name = models.CharField(max_len=32) passwd = models.CharField(max_len=64) age = models.IntegerField() """ create table myapp_user( id bigint auto_increment primary key, name varchar(32), passwd varchar(64), age int ) """ Make sure that we have registered our ‘myapp’ in ‘mysite’ project.

Continue reading

MySQL

1. install brew install mysql mysql.server start mysql_secure_installation Root1234@ See details for installation. If you get an error “The server quit without updating PID file (xxx.lock.pid)” while running the commands above, you can remove the file “/tmp/mysql.sock” and try again. 2. basics mysql -u root -p mysql> show databases; mysql> create database table_name; mysql> use table_name; mysql> create table test( id int auto_increment primary key, name varchar(16) not null, age int default 18, salary decimal(8,2), birth datetime ); mysql> show tables; mysql> insert into test values (1, "zhang san", 23); mysql> insert into test (name, age) values ("li si", 25), ("wang wu", 27); mysql> select * from test where id>3; mysql> delete from test where id=1; mysql> update test set name="abc" where id=2; mysql> drop table test; mysql> drop database table_name; mysql> exit; 3.

Continue reading

Django Quick Start

1. Preparation Firstly, we can install django and create our project as follows. # to install django framework pip install django pip install djangorestframework # create our applications django-admin startproject mysite cd mysite python managy.py startapp myapp To test the project, we can use “runserver” command. python manage.py runserver 2. Models In the file “myapp/models.py”, we can create some models to specify the layout of our database. from django.db import models class User(models.

Continue reading

Nginx

1. Function Load Balance(负载均衡) and Reverse Proxy(反向代理). https://www.runoob.com/linux/nginx-install-setup.html 2. Command nginx nginx -s reload # reload config file.

Continue reading

Author's picture

LI WEI

苟日新,日日新,又日新

Not yet

Tokyo