python-crud

Python Fast CRUD

https://github.com/aleimu/python-crud

purpose

This project uses a series of Python in popular assemblies, can quickly build this project-based Restful Web API, here is mainly to put some common examples of CRUD operations and general functions their accumulated.

Explanation

This project uses the following common components:

  1. The Flask : lightweight Web framework, arguably the most use of the Python
  2. SQLAlchemy-the Flask : ORM tool. The project needs with the use Mysql, sqlalchemy the flask packaging, easier to use
  3. Redis : Redis Python Client
  4. apscheduler : Python common timing task management library
  5. Excel-the Flask : report export
  6. This project is the use of token authentication,

This project has been previously achieved some common code reuse and for ease of reference:

  1. Creating a user model
  2. To achieve a /v1/user/registeruser registration interface
  3. Implements /v1/user/loginuser login interfaces
  4. It implements /v1/user/logoutuser interfaces out (after need to log in to obtain token)
  5. Pictures grouped CRUD /v1/advert/group,/v1/advert/image
  6. Strategies show pictures of CRUD /v1/advert/style
  7. Picture of visits and access connections triggered / clicks / statistics CRUD /v1/advert/list, /v1/advert/statistic,

The project has previously created a series of folders divided into the following modules:

  1. app put examples app, db, log in
  2. model folder database responsible for storing the model code and database-related operations
  3. put the route route incoming requests and pretreatment
  4. service is responsible for handling more complex business, the business model of the code can effectively improve the quality of service code (such as user registration, recharge, orders, query lists, etc.)
  5. redis local cache and cache responsible for the relevant code
  6. tools to put some common gadget, function, convenient server in the entire call
  7. help devolution test (test file here not completion), db_script (change script for the mysql database table structure put all previous versions), and a description of previous versions of files as well as some help
  8. put the logs generated by the operation log file

Running locally

python runserver.py

When the project started in 3000 to run the port (you can modify, Flask reference document), you can configure (regular statistic views / clicks of) whether to enable regular tasks

Production environment is recommended to use nginx proxy uwsgi_config.ini

--This uwsgi uwsgi_config.ini --daemonize /var/log/flask_crud.log

server {
    listen 3001 default_server;
    server_name localhost;
    location /static/ {
        root /data/;
        expires 30d;
    }
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/simpleflask.sock; # 必须和uwsgi_config.ini 中的socket配置一致
        # 并且需要权限
    }
}

reference

https://github.com/openspug/spug of crud and has a good package, it is also useful

Guess you like

Origin www.cnblogs.com/lgjbky/p/11271345.html