1. Project introduction
The project is a company official website developed using the flask framework and Tencent Cloud development cms. Its main function is to request cloud development cms through requests, and then render it on the page.
Software Architecture
- Front-end UI framework: layui
- Server: flask
- Backend API: Cloud Development CMS
Second, the deployment project
WeChat cloud hosting deployment flask project
1. First clone this project to the local (or download the compressed package directly)
https://github.com/hzjsj/flaskProject.git
2. Visit WeChat cloud hosting official website , create a cloud environment, select the service list, and then create a new service
3. In the service list, click Manage to enter the service details page, and click New Version in the version list option
Here you can choose to pull the code library, you need to authorize your own github, gitlab or gitlab, and you need to upload the current project code to your own git repository.
You can also choose to upload from the local code, enter the project root directory to compress the file, and upload the compressed package.
4. After the new version status is normal, you can go to the deployment release option to release the project
5. In the service list option, click on the service details, you can see the public domain name, copy it to the browser to open
6. There is a container loading process for the first visit, which will be slower. After the visit is successful, you can see the following figure
At this point, the project is successfully deployed. The back-end API accesses the domain name. If you want to change to yourself, you need to install cloud development cms.
Cloud development cms extension installation
1. Check the official documentation for installation
https://docs.cloudbase.net/cms/install/extension.html
After the installation is successful, in the extended basic information option, you can see the access address and the administrator account password
2. Visit the address, log in to the background, and create a project
3. In the content model, click Import Model to upload the flask-project.json file in the project root directory
4. In the project settings, configure the access permissions (you need to go to the system settings first, open the API access, and keep the configuration path)
5. Configure the main.py file in the root directory of the project
headers = {
'Authorization': 'Bearer API_TOKEN'
}
api = ''
Copy the above access link and fill in the api, so that the configuration is complete, and finally add data according to your needs.
You can also set for API to request authentication , and modify API_Token to the Token created by the system
6. Local debugging, run main.py
http://localhost:8080
After the configuration is complete, just redeploy the project.
3. Project summary
When using WeChat Cloud Hosting, pay attention to writing the Dockerfile file. You can check the WeChat Cloud Hosting official document , and refer to the sample code to configure the Dockerfile file.
related documents:
Front-end UI framework: https://www.layui.com/
flask documentation: https://dormousehole.readthedocs.io/en/latest/
Cloud development CMS: https://docs.cloudbase.net/cms/intro.html
API request document: https://docs.cloudbase.net/cms/usage/restful/intro.html#api-qing-qiu
WeChat Cloud Hosting: https://cloud.weixin.qq.com
WeChat Cloud Hosting Document: https://developers.weixin.qq.com/miniprogram/dev/wxcloudrun/src/basic/guide.html
Author: Cloud Development Evangelist Wang Xiulong
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。