The first article and subsequent updates: https://mwhls.top/4087.html , no picture/no directory/format error/more information, please go to the first page to view. Please check mwhls.top
for new updates . Any questions and criticisms are welcome, thank you very much!
The flying paddle model is deployed to docker and called using FastAPI
foreword
- Because I want to deploy it to my blog, I call the API through PHP in WordPress, so some WordPress content will be involved.
- But because it's inserted into WordPress as a shortcode, it's actually still PHP.
Environment configuration
PHP installation
- Download PHP 7.4.30 , unzip it, and add the decompression path to the environment variable.
- However, there are integrated packages, such as XAMPP, which are more convenient.
- Vscode opens any php file, and adds the path where php.exe is located to the json that prompts an error in the pop-up window.
- Note:
- It's relatively simple here, because you know everything you know, and Baidu if you don't know it.
- And it’s not necessary here, just to let VSCode not pop up windows to disturb me.
VSCode PHP plugin
- Install plugins PHP Debug, PHP Intelphense, PHP Extension Pack.
- It’s okay to be uneasy, I want to modify the variable name globally, but the above three seem to have no such function.
VSCode connect server
Install the plugin sftp.
ctrl+ shift+ pand enter
>sftp: config
to configure the connection information, the configuration is as follows:{ "name": "mwhls", "host": "mwhls.top", "protocol": "ftp", "port": 21, "username": "mwhls", "password": "mwhls", "remotePath": "/", "uploadOnSave": true, "ignore":[ ".vscode", ".git", ".DS_Store", "wp-content/cache" ] }
After configuration, find SFTP in the activity column on the left to initiate an FTP connection.
Synchronize FTP files to local
Right-click on the resource manager, select Sync Remote -> Local , and wait for the long download.
Or click Sync Remote -> Local for a single folder after it has synchronized the folders .
After using the above configuration and synchronizing the files locally, the following functions can be realized:
- After the file is modified, it is automatically synchronized to the server.
- The /wp-content/cache folder in the server and the local .vscode folder are no longer synchronized.
- but added wen'j
SFTP log output
- After startup, you can see SFTP on the left side of the lower status bar, click to jump to the log output of SFTP
WordPress plugins
Insert PHP Code Snippet
- I found this plugin in the official plugin library . The introduction and simple translation are as follows:
★ Convert PHP snippets to shortcodes # PHP 代码段转换为短代码
★ Insert PHP code easily using shortcode # 将 PHP 以短代码形式插入
★ Support for PHP snippet shortcodes in widgets # 小工具支持短代码
★ Dropdown menu in TinyMCE editor to pick snippet shortcodes easily # 可在 TinyMCE 编辑器的下拉菜单中插入短代码
- After enabling the plugin, XYZ PHP Code has been added to the left menu bar .
- Calling the API and displaying the results requires the following functions:
- Upload and download pictures and automatically delete expired pictures.
- Image display box and description box.
Test – Hello world
- First search for PHP tutorials and recall PHP that you haven't learned.
- The first one is the rookie tutorial. I think it seems that which tutorial website was written by one person, which is really amazing.
- In XYZ PHP Code – PHPCode Snippets, select Add New PHP Code Snippet to create a shortcode.
- Name: Hello-world
- Test code:
<?php echo "Hello World!"; ?>
- Shortcode for insertion:
- Create a new page to test
- Add Widget – Shortcode with content:
, published, see this page: PHP shortcode test .
- Very unpretentious on display
Hello World!
.
- Add Widget – Shortcode with content: