GithubHelp home page GithubHelp logo

kamasassoonn / mywebserver-flask Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rrroger/mywebserver-flask

0.0 0.0 0.0 1.25 MB

python + flask + LayUI + mysql 网站模板

License: MIT License

Shell 0.23% JavaScript 14.01% Python 52.79% CSS 4.51% HTML 28.45%

mywebserver-flask's Introduction

My WebServer

GitHub last commit GitHub issues GitHub last commit GitHub

Flask网站模板

python + flask + LayUI + mysql

Technology stack

Features

  • 增删改查操作

  • 用户管理

  • 角色管理

  • 权限管理

  • 接口日志

  • 搜索、分页

  • 异常捕获

Init

  • 添加环境变量
export FLASK_APP=hello.py
  • 创建数据库
# 进入数据库
mysql -uroot -p

# 创建爱你数据库
create database test_db charset=utf8;
  • 初始化数据库
flask db init

# 第一次先删除`migrations`目录
rm -rf migrations

flask db migrate

# 修改数据库结构
flask db upgrade
  • 初始化用户数据
# 初始化用户数据
flask init-tables

Run

1. 普通启动方式

python hello.py

2. with gunicorn

  • 安装gunicorn & gevent
pip install gunicorn
pip install gevent
  • 使用gunicorn启动服务
cd MyWebserver-flask

gunicorn -c gunicorn.conf.py  hello:app  --preload -b 0.0.0.0:5000

# 后台启动
gunicorn -c gunicorn.conf.py  hello:app  --preload -b 0.0.0.0:5000 --daemon

如何关闭进程?

  • ps -ef|grep gunicorn
roger    12434     1  0 15:15 ? 00:00:02 ...... -b 0.0.0.0:5000 --daemon
roger    12442 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12443 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12444 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12445 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12446 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12447 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12448 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12449 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
roger    12450 12434  0 15:15 ? 00:00:01 ...... -b 0.0.0.0:5000 --daemon
  • 删除父进程
kill -9 12434

查看日志

# 访问日志
tail -f ~/log/gunicorn_access.log

# 接口日志
tail -f ~/log/gunicorn_info.log

mywebserver-flask's People

Contributors

rrroger avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.