update
This commit is contained in:
parent
416ac2644d
commit
a73127c5e6
@ -1,5 +1,8 @@
|
||||
# flask
|
||||
|
||||
信任尾缀
|
||||
`--trusted-host mirrors.aliyun.com`
|
||||
|
||||
安装venv
|
||||
|
||||
`python3 -m venv venv`
|
||||
@ -31,7 +34,7 @@
|
||||
安装pymongo
|
||||
|
||||
` pip install pymongo`
|
||||
|
||||
` pip install pymongo==3.2`
|
||||
安装requests
|
||||
|
||||
` pip install requests`
|
||||
@ -45,13 +48,14 @@
|
||||
`export FLASK_APP=yiban.py`
|
||||
`export FLASK_APP=qrcodeLi.py`
|
||||
`export FLASK_APP=coc.py`
|
||||
`export FLASK_APP=app.py`
|
||||
`export FLASK_APP=api.py`
|
||||
`export FLASK_APP=ccb.py`
|
||||
|
||||
`export FLASK_ENV=development`
|
||||
|
||||
启动
|
||||
|
||||
`flask run --host=127.0.0.1 -p 5003`
|
||||
`flask run --host=127.0.0.1 -p 5004`
|
||||
`flask run --host=0.0.0.0 -p 5000`
|
||||
|
||||
在虚拟环境下安装gunicorn
|
||||
@ -82,6 +86,8 @@ autostart = True
|
||||
`gunicorn qrcodeMe:app -c gunicornMe.conf`
|
||||
`gunicorn yiban:app -c gunicorn.conf`
|
||||
`gunicorn coc:app -c gunicorn.conf`
|
||||
`gunicorn api:app -c gunicorn.conf`
|
||||
`gunicorn ccb:app -c gunicorn.conf.py`
|
||||
|
||||
查询gunicorn
|
||||
|
||||
|
@ -29,4 +29,7 @@
|
||||
|
||||
## ES6
|
||||
* let 尽量将变量声明放在代码块开始,避免在(Temproal Dead Zone, TDZ)临时死亡区使用而报错
|
||||
* 尽量使用for...let,在每次循环中都会声明一个新的变量,生成了一个闭包。避免for里边的函数在调用的时候引用不到正确的变量。
|
||||
* 尽量使用for...let,在每次循环中都会声明一个新的变量,生成了一个闭包。避免for里边的函数在调用的时候引用不到正确的变量。
|
||||
* const声明,相对于保护其中的内容更注重其语意所带来的规范性
|
||||
* 如果把方法定义在{}内,那么在块外执行会报ReferenceError
|
||||
* spread/rest`...`放在数组前用于展开数组,放在变量前就是收集变量到一个数组里,例如 `function a(...arg){} a(a,b,c) -> arg = [a,b,c]`
|
@ -25,6 +25,20 @@ db.createUser(
|
||||
roles: [ { role: "dbOwner", db: "code" }]
|
||||
}
|
||||
)
|
||||
db.createUser(
|
||||
{
|
||||
user: "coc",
|
||||
pwd: "qlSfefSor5",
|
||||
roles: [ { role: "dbOwner", db: "coc" }]
|
||||
}
|
||||
)
|
||||
db.createUser(
|
||||
{
|
||||
user: "apiwx",
|
||||
pwd: "srVgEGwTf4",
|
||||
roles: [ { role: "dbOwner", db: "apiwx" }]
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### log目录 `/var/log/mongodb/mongod.log`
|
||||
@ -49,11 +63,19 @@ mongo --port 12236 -u "admin" -p "rqRrjTDaq9" --authenticationDatabase "admin"
|
||||
mongo --port 12236 -u "yingbo" -p "623910ert" --authenticationDatabase "yingbo"
|
||||
mongo --port 12236 -u "code" -p "rtRrjfSau8" --authenticationDatabase "code"
|
||||
mongo --port 12236 -u "yiban" -p "623910ert" --authenticationDatabase "yiban"
|
||||
mongo --port 12236 -u "apiwx" -p "srVgEGwTf4" --authenticationDatabase "apiwx"
|
||||
mongo --port 12236 -u "coc" -p "qlSfefSor5" --authenticationDatabase "coc"
|
||||
//方法二
|
||||
db.auth("yingbo", "623910ert")
|
||||
db.auth("yiban", "623910ert")
|
||||
db.auth("admin", "rqRrjTDaq9")
|
||||
db.auth("code", "rtRrjfSau8")
|
||||
db.auth("coc", "qlSfefSor5")
|
||||
db.auth("apiwx", "srVgEGwTf4")
|
||||
|
||||
// pi
|
||||
db.addUser('ccb', 'srVgEGwTf4')
|
||||
db.auth("ccb", "srVgEGwTf4")
|
||||
```
|
||||
|
||||
### 显示所有数据库
|
||||
|
@ -1,3 +1,56 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /data/wwwroot;
|
||||
index index.html index.htm;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name powerrain.cn;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
location / {
|
||||
root /data/wwwroot;
|
||||
index index.html index.htm;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/main.log;
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
listen 443 ssl http2; #填写绑定证书的域名
|
||||
server_name powerrain.cn;
|
||||
#证书文件名称
|
||||
ssl_certificate 1_powerrain.cn_bundle.crt;
|
||||
#私钥文件名称
|
||||
ssl_certificate_key 2_powerrain.cn.key;
|
||||
ssl_session_timeout 5m;
|
||||
#请按照这个协议配置
|
||||
ssl_protocols TLSv1.1 TLSv1.2;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
location / {
|
||||
root /data/wwwroot;
|
||||
index index.html index.htm;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/main443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
@ -26,6 +79,42 @@ server {
|
||||
location /li {
|
||||
proxy_pass http://127.0.0.1:5001;
|
||||
}
|
||||
access_log /data/nginx/logs/qr443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name api.powerrain.cn;
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5004;
|
||||
}
|
||||
location /excel/get/ {
|
||||
alias /data/api/saveExcel/;
|
||||
}
|
||||
access_log /data/nginx/logs/api.log;
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
listen 443 ssl http2; #填写绑定证书的域名
|
||||
server_name api.powerrain.cn;
|
||||
#证书文件名称
|
||||
ssl_certificate 1_api.powerrain.cn_bundle.crt;
|
||||
#私钥文件名称
|
||||
ssl_certificate_key 2_api.powerrain.cn.key;
|
||||
ssl_session_timeout 5m;
|
||||
#请按照这个协议配置
|
||||
ssl_protocols TLSv1.1 TLSv1.2;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5004;
|
||||
}
|
||||
location /excel/get/ {
|
||||
alias /data/api/saveExcel/;
|
||||
}
|
||||
access_log /data/nginx/logs/api443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -40,6 +129,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/blog.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -64,6 +154,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/blog443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -88,6 +179,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/yb.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -122,6 +214,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/yb443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -146,6 +239,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/myb.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -180,6 +274,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/myb443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -199,6 +294,7 @@ server {
|
||||
# root /data/wwwroot;
|
||||
# }
|
||||
return 301 https://coc.powerrain.cn$request_uri;
|
||||
access_log /data/nginx/logs/coc.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -223,10 +319,14 @@ server {
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:5003;
|
||||
}
|
||||
location /api/photo/show/ {
|
||||
alias /data/coc/backEnd/upload/;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/coc443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -241,6 +341,7 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/main.log;
|
||||
}
|
||||
|
||||
server {
|
||||
@ -265,18 +366,6 @@ server {
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
access_log /data/nginx/logs/main443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /data/wwwroot;
|
||||
index index.html index.htm;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /data/wwwroot;
|
||||
}
|
||||
}
|
140
Miscellaneous/nginx_pi.conf
Normal file
140
Miscellaneous/nginx_pi.conf
Normal file
@ -0,0 +1,140 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name canary.moe;
|
||||
location / {
|
||||
root /home/pi/data/wwwroot;
|
||||
}
|
||||
access_log /home/pi/data/nginx/logs/home.log;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name ccb.canary.moe;
|
||||
return 301 https://ccb.canary.moe$request_uri;
|
||||
access_log /home/pi/data/nginx/logs/ccb.log;
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
listen 443 ssl http2; #填写绑定证书的域名
|
||||
server_name ccb.canary.moe;
|
||||
#证书文件名称
|
||||
ssl_certificate 1_ccb.canary.moe_bundle.crt;
|
||||
#私钥文件名称
|
||||
ssl_certificate_key 2_ccb.canary.moe.key;
|
||||
ssl_session_timeout 5m;
|
||||
#请按照这个协议配置
|
||||
ssl_protocols TLSv1.1 TLSv1.2;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
#请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
location / {
|
||||
root /home/pi/data/ccb/foreEnd;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:5005;
|
||||
}
|
||||
access_log /home/pi/data/nginx/logs/ccb443.log;
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
listen 443 ssl http2; #填写绑定证书的域名
|
||||
server_name pi.powerrain.cn;
|
||||
#证书文件名称
|
||||
ssl_certificate 1_pi.powerrain.cn_bundle.crt;
|
||||
#私钥文件名称
|
||||
ssl_certificate_key 2_pi.powerrain.cn.key;
|
||||
ssl_session_timeout 5m;
|
||||
#请按照这个协议配置
|
||||
ssl_protocols TLSv1.1 TLSv1.2;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
#请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
location /html {
|
||||
root /var/www/html;
|
||||
index index.html index.htm index.nginx-debian.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name pi.powerrain.cn;
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
location /html {
|
||||
root /var/www/html;
|
||||
index index.html index.htm index.nginx-debian.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
listen 443 ssl http2; #填写绑定证书的域名
|
||||
server_name pi.powerrain.cn;
|
||||
#证书文件名称
|
||||
ssl_certificate 1_pi.powerrain.cn_bundle.crt;
|
||||
#私钥文件名称
|
||||
ssl_certificate_key 2_pi.powerrain.cn.key;
|
||||
ssl_session_timeout 5m;
|
||||
#请按照这个协议配置
|
||||
ssl_protocols TLSv1.1 TLSv1.2;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
#请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
location /html {
|
||||
root /var/www/html;
|
||||
index index.html index.htm index.nginx-debian.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name coc.canary.moe;
|
||||
return 301 https://coc.canary.moe$request_uri;
|
||||
access_log /home/pi/data/nginx/logs/coc.log;
|
||||
}
|
||||
|
||||
server {
|
||||
#SSL 访问端口号为 443
|
||||
listen 443 ssl http2; #填写绑定证书的域名
|
||||
server_name coc.canary.moe;
|
||||
#证书文件名称
|
||||
ssl_certificate 1_coc.canary.moe_bundle.crt;
|
||||
#私钥文件名称
|
||||
ssl_certificate_key 2_coc.canary.moe.key;
|
||||
ssl_session_timeout 5m;
|
||||
#请按照这个协议配置
|
||||
ssl_protocols TLSv1.1 TLSv1.2;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
location / {
|
||||
root /home/pi/data/coc/foreEnd;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:5003;
|
||||
}
|
||||
location /api/photo/show/ {
|
||||
alias /home/pi/data/coc/backEnd/upload/;
|
||||
}
|
||||
access_log /home/pi/data/nginx/logs/coc443.log;
|
||||
}
|
||||
|
@ -290,4 +290,17 @@ server {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
# flask自启
|
||||
|
||||
* 写文件
|
||||
```sh
|
||||
#!/bin/sh
|
||||
cd /home/pi/data/ccb/backEnd
|
||||
. venv/bin/activate
|
||||
gunicorn ccb:app -c gunicorn.conf.py
|
||||
```
|
||||
* 给权限`sudo chmod 777 /home/pi/data/ccb/backEnd/start.sh`
|
||||
* 编辑开机自启`sudo nano /etc/rc.local`
|
||||
* 添加`/home/pi/data/ccb/backEnd/start.sh start`
|
@ -45,4 +45,23 @@ server {
|
||||
## 常见问题
|
||||
|
||||
* store的对象可以直接更改,换另一个变量存着也是同一个内存地址,,尽量避免直接操作
|
||||
* var newObj = JSON.parse(JSON.stringify(obj)); 可以这样深拷贝
|
||||
* var newObj = JSON.parse(JSON.stringify(obj)); 可以这样深拷贝
|
||||
|
||||
# vue typescript
|
||||
* Component 装饰器 可以像类一样写
|
||||
* 变量定义为undefined将不会具备更新视图的功能,如需要请用null,或者使用data钩子,写在return里边
|
||||
* 组件的方法可以直接写在类里边
|
||||
* 计算方法为get和set
|
||||
* Component组件引用
|
||||
```js
|
||||
import OtherComponent from './OtherComponent.vue'
|
||||
@Component({
|
||||
// Specify `components` option.
|
||||
// See Vue.js docs for all available options:
|
||||
// https://vuejs.org/v2/api/#Options-Data
|
||||
components: {
|
||||
OtherComponent
|
||||
}
|
||||
})
|
||||
* msg!: string 感叹号值得是告诉编译器这里一定有值
|
||||
|
Loading…
x
Reference in New Issue
Block a user