diff --git a/README.en-US.md b/README.en-US.md new file mode 100644 index 0000000..00e541f --- /dev/null +++ b/README.en-US.md @@ -0,0 +1,68 @@ + + +# Python Fast CRUD + +https://github.com/aleimu/python-crud + +## Purpose + +This project utilizes a series of popular Python components. It can be used as a foundation to quickly build RESTful Web APIs. It primarily includes common CRUD operation examples and general-purpose functions accumulated over time. + +## Description + +This project uses the following common components: + +1. [Flask](https://github.com/pallets/flask): A lightweight web framework, arguably the most user-friendly in Python. +2. [Flask-SQLAlchemy](https://github.com/pallets/flask-sqlalchemy): An ORM tool. This project requires MySQL. It uses Flask's wrapper for SQLAlchemy, making it easier to use. +3. [Redis](https://github.com/andymccurdy/redis-py): Python Redis client. +4. [apscheduler](https://github.com/agronholm/apscheduler): A commonly used scheduled task management library for Python. +5. [Flask-Excel](https://github.com/pyexcel-webwares/Flask-Excel): For report/export functionality. +6. This project uses token-based authentication. + +The project has pre-implemented some common code for easy reference and reuse: + +1. Created a user model. +2. Implemented the ```/v1/user/register``` user registration endpoint. +3. Implemented the ```/v1/user/login``` user login endpoint. +4. Implemented the ```/v1/user/logout``` user logout endpoint (requires obtaining a token after login). +5. CRUD for image groups: ```/v1/advert/group```, ```/v1/advert/image```. +6. CRUD for image display strategies: ```/v1/advert/style```. +7. CRUD for access views/clicks/statistics triggered by image and link access: ```/v1/advert/list```, ```/v1/advert/statistic```. + +## The project has pre-created a series of folders to organize the following modules: + +1. `app`: Contains instances for the app, database, and logging. +2. `route`: Contains routing configurations and preprocessing for incoming requests. +3. `service`: Handles more complex business logic. Modeling business code effectively improves its quality (e.g., user registration, recharge, order placement, list queries, etc.). +4. `cache`: Contains code related to Redis and local caching. +5. `tools`: Contains general utilities and functions for easy invocation throughout the server. (`model` is responsible for storing database models and database operation-related code.) +6. `help`: Contains `test` (test files are incomplete here), `db_script` (migration scripts for MySQL database/table structure changes across versions), version release notes, and some helper documents. +7. `logs`: Stores log files generated during runtime. + +## Running Locally + +```shell +python runserver.py +``` + +The project starts on port 3000 (modifiable, see Flask documentation). You can configure whether to enable scheduled tasks (e.g., periodic statistics for views/clicks). + +## For production environments, it is recommended to use Nginx as a reverse proxy with uwsgi_config.ini +uwsgi --ini 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; # Must match the socket configuration in uwsgi_config.ini + # And requires proper permissions + } +} +``` + +## Note: The information in `tools/tools_readme.md` will help you understand the project structure.