Deploy the flying paddle model to docker and call it using FastAPI (4) -PHP shortcode in WordPress

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.

    • I use the one released by liximomo. Although it has 4 stars, the 5-star sftp released by Natizyskunk is actually a fork from liximomo.
    • And liximomo's wiki is more comprehensive, see GitHub , config instructions see this wiki .
  • ctrl+ shift+ pand enter >sftp: configto 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:

    1. After the file is modified, it is automatically synchronized to the server.
    2. 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

★ 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:
    1. Upload and download pictures and automatically delete expired pictures.
    2. 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!.

appendix

references

  1. Vscode remote synchronization plug-in SFTP use
  2. PHP Novice Tutorial
  3. Three ways to embed html code in php

Guess you like

Origin blog.csdn.net/asd123pwj/article/details/128065152