I. Project introduction

The project is a company official website developed by flask framework and Tencent cloud development CMS. The main function is to request data from the cloud development CMS through Requests and then render it to the page.

Software architecture

  1. Front-end UI framework: LayUI
  2. Flask server: flask
  3. Backend API: Cloud development CMS

Deployment projects

Wechat cloud hosting deployment Flask project

1. Clone the project to a local computer (or download the package directly) github.com/hzjsj/flask…

2. Visit the official website of wechat Cloud management, create a cloud environment, select the service list, and create a service

3. In the service list, click Manage. On the service details page, click Create version in the version list

Here you can choose the code library, you need to authorize your own Github, GitLab or GitLab, you need to upload the current project code code to your own Git repository.

Alternatively, you can upload the compressed file from the local code to the project root directory and upload the compressed package. 4. After the new version is normal, you can go to the deployment release option and publish the project

5. In the service list, click Service Details. The public domain name is displayed

6. The first access is slow due to the container loading process. After successful access, you can see the following figure

At this point, the project is successfully deployed, where the back-end API accesses the domain name, and you need to install your own cloud development CMS

Cloud development CMS extension installation

1. View the installation documents

Docs.cloudbase.net/cms/install…

After the installation is successful, the access address and administrator account password are displayed in the extended Basic Information option

2. Access the address, log in to the background, and create a project

3. In the content model, click Import model and upload the flask-project.json file in the root directory of the project

4. In the project Settings, configure access permissions (go to system Settings first, enable API access, and maintain the configuration path).

5. Configure the main.py file in the root directory of the project

headers = {
    'Authorization': 'Bearer API_TOKEN'
}
api = ''
Copy the code

Copy the access link above, fill in the API, and then you are configured, and finally add data as you need.

You can also set request authentication for the API to change the Token created by the system in the API_Token

6. Run main.py for local debugging

http://localhost:8080
Copy the code

After the configuration is complete, redeploy the project

Iii. Project Summary

When using wechat cloud hosting, pay attention to the preparation of Dockerfile file, you can view the official documents of wechat cloud hosting, refer to the example code to configure the Dockerfile file.

Related documents:

Front-end UI framework: www.layui.com/

Flask document: dormousehole. Readthedocs. IO/en/latest /

Cloud development CMS:docs.cloudbase.net/cms/intro.h…

The API request document: docs.cloudbase.net/cms/usage/r…

Wechat cloud hosting: cloud.weixin.qq.com

WeChat cloud hosting documentation: developers.weixin.qq.com/miniprogram…

Author: Cloud development evangelist Wang Xiulong