HTML template processing method and device, equipment and storage medium
By introducing template service modules in the backend server, establishing the mapping relationship between HTML template identifiers and unified resource locators, and updating templates locally on the backend server, the problem of inefficient maintenance of HTML template hosting and update updates is solved, ensuring that the front-end obtains the latest templates , solves the problem of untimely update of templates caused by distribution delay.
Patent Information
- Application Number
- CN202411237749.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2025-01-10
AI Technical Summary
The existing HTML template hosting methods have problems such as inconvenient update maintenance, inefficient update efficiency and delayed distribution, resulting in the front-end not being able to obtain the latest templates, especially in back-end servers and content distribution networks (CDN) environments.
Introduce template service module in the backend server, establish mapping relationships by obtaining the template identifier of the HTML template and unified resource locator, download and store HTML templates locally from the source server, and automatically update the local templates when the template is updated, avoiding developers manually Intervention.
Improve the efficiency of updating and maintaining HTML templates, ensure that the templates obtained from the front end are up to date, and avoid the problem of untimely update of templates caused by delays in distribution.
Smart Images

Figure CN119293362A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software engineering, and in particular to an HTML template processing method, device, equipment and storage medium. Background Art
[0002] Hypertext Markup Language (HTML) is a standard markup language used to create web pages and web applications. It defines the structure and content of a web page through a series of tags and attributes. In the web development scenario, web pages are constructed based on the document structure predefined by HTML, namely HTML templates. HTML templates contain the source code necessary for constructing web pages on the front end (such as the browser side). HTML templates are hosted on other servers to facilitate the front end to obtain HTML templates from the server where the HTML templates are hosted to construct web pages.
[0003] When the HTML template is hosted on the back-end server, the back-end developer usually deploys the HTML template developed by the front-end developer on the back-end server. If the HTML template is updated, the front-end developer re-sends the updated HTML template to the back-end developer so that the back-end developer re-deploys the updated HTML template on the back-end server. This HTML template hosting method has the problems of cumbersome operation and inconvenient HTML template update and maintenance.
[0004] When the HTML template is hosted on a server in a content delivery network (CDN), the HTML template is first uploaded to the source server in the CDN, and then the source server distributes the HTML template to the edge server in the CDN. However, due to the distribution delay between the source server and the edge server, the HTML template obtained by the front end from the edge server may not be the latest HTML template; in addition, when the front end obtains the HTML template through the back-end server connected to the edge server, if the edge server currently connected is unavailable, the front-end server may not be able to connect to the available edge server in time, resulting in the front end failing to obtain the HTML template. Summary of the invention
[0005] The embodiments of the present invention provide an HTML template processing method, apparatus, device and storage medium, which are used to improve the updating and maintenance efficiency of HTML template hosting.
[0006] In a first aspect, an embodiment of the present invention provides an HTML template processing method, which is applied to a template service module in a backend server, and the method includes:
[0007] In response to the target HTML template being uploaded to the source server of the content distribution network, obtaining a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server, wherein the target HTML template includes source code for constructing a web page on the front end;
[0008] Establishing a mapping relationship between the template identifier and the uniform resource locator;
[0009] In response to the establishment of the mapping relationship, the target HTML template is downloaded from the source server to a local location, so that the front end can obtain the target HTML template from the local location;
[0010] In response to the update of the target HTML template corresponding to the uniform resource locator, the locally stored target HTML template is updated to the HTML template currently corresponding to the uniform resource locator.
[0011] In a second aspect, an embodiment of the present invention provides an HTML template processing device, which is applied to a template service module in a backend server, and the device includes:
[0012] an acquisition unit, configured to acquire, in response to the target HTML template being uploaded to a source server of a content distribution network, a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server;
[0013] A processing unit, configured to establish a mapping relationship between the template identifier and the uniform resource locator;
[0014] A template management unit is used to download the target HTML template from the source server to a local computer in response to the establishment of the mapping relationship, so that the front end can obtain the target HTML template from the local computer; in response to the update of the target HTML template corresponding to the uniform resource locator, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator.
[0015] In a third aspect, an embodiment of the present invention provides a backend server, the backend server comprising:
[0016] The template service module is used for, in response to the target HTML template being uploaded to the source server of the content distribution network, obtaining the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server; establishing a mapping relationship between the template identifier and the uniform resource locator; in response to the establishment of the mapping relationship, downloading the target HTML template from the source server to the local; in response to the update of the target HTML template corresponding to the uniform resource locator, updating the locally stored target HTML template to the HTML template corresponding to the current uniform resource locator;
[0017] Business service module, used to execute business logic and database operations.
[0018] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the HTML template processing method described in the first aspect.
[0019] In a fifth aspect, an embodiment of the present invention provides a non-transitory machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the HTML template processing method described in the first aspect.
[0020] In a sixth aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program, when the computer program is executed by a processor of an electronic device, the processor can at least implement the HTML template processing method as described in the first aspect.
[0021] In the solution provided by the embodiment of the present invention, a template service module is configured in the back-end server, and the template service module is used to: in response to the target HTML template being uploaded to the source server of the content distribution network, obtain the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server, the target HTML template contains the source code for building the web page on the front end; establish a mapping relationship between the template identifier and the uniform resource locator; in response to the establishment of the mapping relationship, download the target HTML template from the source server to the local, so that the front end can obtain the target HTML template from the local; in response to the update of the target HTML template corresponding to the uniform resource locator, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator. In this solution, by adding a template service module to the back-end server, the establishment of the mapping relationship between the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server is realized, so that the management operation of the target HTML template can be realized: downloading the target HTML template from the CDN source server to the local, and updating the local target HTML template. Based on the template service module, HTML templates can be automatically updated to the local without the involvement of developers, which can effectively improve the update and maintenance efficiency of the target HTML template when it is hosted. In addition, since the local target HTML template can be updated in time, it can ensure that the target HTML template obtained from the local by the front end is the latest HTML template. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 A flowchart of an HTML template processing method provided by an embodiment of the present invention;
[0024] Figure 2 A flowchart of another HTML template processing method provided by an embodiment of the present invention;
[0025] Figure 3 A flowchart of another HTML template processing method provided by an embodiment of the present invention;
[0026] Figure 4 A flowchart of another HTML template processing method provided by an embodiment of the present invention;
[0027] Figure 5A schematic diagram of a scenario for obtaining a target HTML template provided by an embodiment of the present invention;
[0028] Figure 6 A schematic diagram of the structure of an HTML template processing device provided by an embodiment of the present invention;
[0029] Figure 7 For Figure 6 The illustrated embodiment is a schematic diagram of the structure of an electronic device corresponding to the HTML template processing device. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0032] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and the features in the embodiments can be combined with each other. In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0033] First, relevant concepts involved in the embodiments of the present invention are explained.
[0034] Hypertext Markup Language (HTML) is a standard markup language used to create web pages and web applications. It defines the structure and content of a web page through a series of tags and attributes.
[0035] HTML template refers to a document structure predefined based on HTML for building web pages. HTML template contains source code that defines the structure and content of a web page. The front-end interface of a website or web application can be built based on HTML template.
[0036] Front-end and back-end separation refers to a software development architecture model that divides traditional websites or web applications into two independent parts: the front-end and the back-end.
[0037] The front end refers to the user interface and user experience, which is usually implemented by technologies such as HTML, Cascading Style Sheets (CSS), and JavaScript. The front end runs in the user's browser and is responsible for displaying data and interacting with the user, and is also commonly referred to as the browser end.
[0038] The backend refers to the business logic processing part and the database operation part (such as database access, etc.), which is usually implemented using server-side languages such as Node.js, Python, Java, Hypertext Preprocessor (PHP), etc. The backend is also called the server side, and provides an Application Programming Interface (API) for the front-end to call. The backend runs on the background server and implements business logic processing and database operations by utilizing the computing resources and storage resources of the backend server.
[0039] In order to facilitate the front-end to build web pages based on HTML templates, in actual applications, various HTML templates are usually hosted in a server accessible to the front-end, so that the front-end can obtain the HTML template corresponding to the web page to be built from the server at any time. However, the existing HTML template hosting has the problem of low update efficiency.
[0040] For example, in the scenario where the HTML template is hosted on a back-end server, the HTML template is usually developed by a front-end developer first; then, the front-end developer sends the developed HTML template to the back-end developer, who deploys the HTML template on the back-end server so that the source code in the HTML template can run and the user can access the web page built based on the HTML template through the URL or website address. In the process of hosting the HTML template on the back-end server, when the HTML template needs to be updated, the front-end staff sends the updated content of the HTML template to the back-end developer, who redeploys the updated content of the HTML template on the back-end server. This process is cumbersome and the update efficiency is low. In addition, since the back-end developer is not the developer of the HTML template, he has limited knowledge of the HTML template, and there is a problem of deployment difficulty when deploying the updated content of the HTML template. Therefore, the existing solution of hosting the HTML template on the back-end server has the problem of low update and maintenance efficiency.
[0041] For another example, in a scenario where an HTML template is hosted on a server in a content delivery network (CDN), the HTML template is usually first uploaded to a source server in the CDN, and then the source server distributes the HTML template to an edge server in the CDN, so that the front end can obtain the HTML template from an edge server that is closer. In actual applications, the front end can obtain the HTML template directly from the edge server, or it can obtain the HTML template from the edge server through a back-end server. However, due to the problem of distribution delay between the source server and the edge server, the HTML template uploaded to the source server cannot be distributed to the edge server in a timely manner. Therefore, the HTML template obtained by the front end from the edge server may not be the latest HTML template. In addition, when the front end obtains the HTML template through the back-end server connected to the edge server, if the edge server of the current communication connection is unavailable, the front end server may not be able to connect to the available edge server in time, which leads to the front end failing to obtain the HTML template. Therefore, the existing solution of hosting the HTML template on a server in the CDN has the problem that the HTML template in the edge server is not updated in time, and the HTML template may not be obtained.
[0042] To solve at least one of the above technical problems, an embodiment of the present invention provides a back-end server, which includes: a business service module and a template service module. The business service module is used to execute business logic and database operations. The template service module is used to obtain the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server in response to the target HTML template being uploaded to the source server of the content distribution network; establish a mapping relationship between the template identifier and the uniform resource locator; download the target HTML template from the source server to the local in response to the establishment of the mapping relationship; and update the locally stored target HTML template to the HTML template corresponding to the current uniform resource locator in response to the update of the target HTML template corresponding to the uniform resource locator.
[0043] Simply put, in the back-end server provided in the embodiment of the present invention, the business logic and database operations that the back-end server originally needs to execute are implemented through the business service module; at the same time, a template service module is newly added to the back-end server to achieve flexible management of HTML templates through the template management function provided by the template service module, thereby solving the problem of low efficiency of HTML template updates in related technologies.
[0044] The following describes the template management function provided by the template service module through a specific embodiment, that is, describes the HTML template processing method provided by the embodiment of the present invention.
[0045] The HTML template processing method provided in the embodiment of the present invention is executed by a template service module in a backend server, wherein the backend server may be a physical server including an independent host, or may be a virtual server, or may be a cloud server or a server cluster.
[0046] Optionally, the backend server may be a Node.js server. Node.js is a JavaScript runtime environment based on the Chrome V8 JavaScript engine, allowing developers to use JavaScript to write server-side applications.
[0047] Figure 1 A flowchart of an HTML template processing method provided by an embodiment of the present invention, such as Figure 1 As shown, the following steps may be included:
[0048] 101. In response to a target HTML template being uploaded to a source server of a content distribution network, a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server are obtained.
[0049] 102. Establish a mapping relationship between the template identifier of the target HTML template and the uniform resource locator.
[0050] 103. In response to the establishment of the mapping relationship, the target HTML template is downloaded from the source server to the local computer so that the front end can obtain the target HTML template from the local computer.
[0051] 104. In response to the update of the target HTML template corresponding to the uniform resource locator, the locally stored target HTML template is updated to the HTML template currently corresponding to the uniform resource locator.
[0052] In the embodiment of the present invention, the target HTML template can be any HTML template developed by the front-end developers and needs to be hosted. The target HTML template contains source code for building a web page on the front end.
[0053] After the front-end developer completes the development of the target HTML template, the target HTML template is uploaded to the source server in the CDN. In response to the target HTML template being uploaded to the source server of the content distribution network, the template service module of the back-end server obtains the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server.
[0054] In an optional embodiment, after the upload operation of uploading the target HTML to the source server in the CDN is completed, a notification of successful HTML template upload can be automatically triggered to be sent to the template service module in the back-end server, so that the template service module can respond to the notification of successful HTML template upload and obtain the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server from the source server.
[0055] In another optional embodiment, the template service module may provide a management interface for configuring HTML template management information. In a specific implementation, in response to an HTML template management operation triggered by a user, the template service module generates an HTML template management interface and sends the HTML template management interface to the front end so that the HTML template management interface is displayed through a terminal device display interface running on the front end; thereafter, according to the configuration operation of the user in the HTML template management interface, the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server are obtained.
[0056] After obtaining the template identifier and uniform resource locator of the target HTML template, a mapping relationship between the template identifier of the target HTML template and the uniform resource locator (URL) is established. It is understandable that the template service module can store mapping relationships between template identifiers of multiple different HTML templates and corresponding URLs at the same time. For example, the template service module includes: mapping relationship 1 - "HTML template ID: 123 - URL123", mapping relationship 2 - "HTML template ID: 234 - URL234", etc.
[0057] The template identifier and uniform resource locator of the target HTML template are recorded in the mapping relationship. Therefore, in response to the establishment of the mapping relationship, the target HTML template can be downloaded from the source server to the local according to the uniform resource locator of the target HTML template in the mapping relationship.
[0058] After the target HTML template is downloaded locally, the template identifier of the target HTML template in the mapping relationship can be used to identify the local HTML template, so that the front end can then obtain the HTML template corresponding to the corresponding template identifier from multiple HTML templates stored locally.
[0059] The above process describes the processing performed by the template service module in the back-end server when the target HTML template is first uploaded to the source server in the CDN for hosting. In the above process, the target HTML template can be automatically stored locally on the back-end server without the need for back-end personnel to participate, which can effectively improve the convenience of target HTML template management. In addition, the template service module promptly and proactively downloads the target HTML template from the source server to the back-end server locally, and the front-end directly obtains the target HTML template locally from the back-end server without having to obtain it from the edge server. This can effectively avoid the problem that when the source server distributes the target HTML template to the edge server, the front-end cannot obtain the latest hosted target HTML template due to distribution delays.
[0060] In actual applications, after uploading the target HTML template to the source server in the CDN for the first time, the target HTML template may have a version update. At this time, the updated target HTML template needs to be re-uploaded to the source server in the CDN to achieve the hosting of the updated target HTML template. To ensure that the front end can obtain the latest version of the target HTML template locally, in this embodiment, the template service module responds to the update of the target HTML template corresponding to the target HTML template uniform resource locator, and updates the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator.
[0061] In summary, in this solution, by adding a template service module to the backend server, the mapping relationship between the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server is established, so that the management operations of the target HTML template can be realized: downloading the target HTML template from the CDN source server to the local, and updating the local target HTML template. Based on the template service module, the HTML template can be automatically updated to the local without the participation of developers, which can effectively improve the update and maintenance efficiency of the target HTML template when it is hosted; in addition, since the local target HTML template can be updated in time, it can ensure that the target HTML template obtained from the local by the front end is the latest HTML template.
[0062] Figure 2 A flowchart of another HTML template processing method provided by an embodiment of the present invention, such as Figure 2 As shown, the following steps may be included:
[0063] 201. In response to a target HTML template being uploaded to a source server of a content distribution network, a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server are obtained.
[0064] 202. Establish a mapping relationship between the template identifier of the target HTML template and the uniform resource locator.
[0065] 203. In response to the establishment of the mapping relationship, the target HTML template is downloaded from the source server to the local computer, so that the front end can obtain the target HTML template from the local computer.
[0066] 204. Obtain the HTML template currently corresponding to the uniform resource locator of the target HTML template.
[0067] 205. Determine whether the HTML template currently corresponding to the uniform resource locator of the target HTML template is consistent with the locally stored target HTML template; if not, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator of the target HTML template.
[0068] The embodiment of the present invention describes the updating process of the target HTML template in detail, wherein the specific implementation process of step 201 to step 203 can refer to the aforementioned embodiment, and will not be described in detail in this embodiment.
[0069] In this embodiment, the target HTML template in the source server remains unchanged corresponding to the same resource locator before and after the update.
[0070] It is understandable that the mapping relationship established by the template service module records the uniform resource locator of the target HTML template. Therefore, the template service module can obtain the HTML template currently corresponding to the uniform resource locator of the target HTML template from the source server at a regular interval according to the uniform resource locator of the target HTML template, for example: periodically obtain the HTML template currently corresponding to the uniform resource locator of the target HTML template from the source server at a preset period. The frequency of obtaining the HTML template currently corresponding to the uniform resource locator of the target HTML template from the source server can be customized.
[0071] Afterwards, it is determined whether the HTML template currently corresponding to the uniform resource locator of the target HTML template is consistent with the locally stored target HTML template. If they are consistent, it indicates that the target HTML template in the source server has not been updated; if they are inconsistent, it indicates that the target HTML template in the source server has been updated.
[0072] In the specific implementation process, when it is determined that the HTML template currently corresponding to the uniform resource locator of the target HTML template is inconsistent with the locally stored target HTML template, the locally stored target HTML template is updated to the HTML template currently corresponding to the uniform resource locator of the target HTML template, so as to implement the update of the local target HTML template. Thus, the front end can obtain the latest target HTML template from the local of the back end server.
[0073] In this embodiment, the template service module of the back-end server automatically determines whether the target HTML template hosted in the source server is updated, and when the target HTML template is updated, the updated target HTML template is updated to the local in a timely manner, thereby ensuring the update efficiency of the target HTML template and enabling the front-end to obtain the latest target HTML template from the local.
[0074] In actual application scenarios, the update of the target HTML template needs to ensure both timeliness and security and stability of the target HTML template. To this end, the template processing method provided in the embodiment of the present invention provides another update process of the target HTML template. Figure 3 Provide an expanded description.
[0075] Figure 3 A flowchart of another HTML template processing method provided by an embodiment of the present invention, such as Figure 3 As shown, the following steps may be included:
[0076] 301. In response to a target HTML template being uploaded to a source server of a content distribution network, a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server are obtained.
[0077] The target HTML template includes source code for building a web page on the front end.
[0078] 302. Establish a mapping relationship between the template identifier of the target HTML template and the uniform resource locator.
[0079] 303. In response to the establishment of the mapping relationship, the target HTML template is downloaded from the source server to the local computer, so that the front end can obtain the target HTML template from the local computer.
[0080] 304. Obtain the HTML template currently corresponding to the uniform resource locator of the target HTML template.
[0081] 305. Determine whether the HTML template currently corresponding to the uniform resource locator of the target HTML template is consistent with the locally stored target HTML template; if not, output prompt information that the target HTML template corresponding to the uniform resource locator of the target HTML template is updated.
[0082] 306. In response to the update instruction triggered by the prompt information, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator of the target HTML template.
[0083] The specific implementation process of step 301 to step 304 may refer to the aforementioned embodiment, and will not be described in detail in this embodiment.
[0084] In this embodiment, when it is determined that the HTML template currently corresponding to the uniform resource locator of the target HTML template is inconsistent with the locally stored target HTML template, prompt information indicating that the target HTML template corresponding to the uniform resource locator of the target HTML template is updated is output.
[0085] Optionally, the prompt information may include version information corresponding to the target HTML template and / or update information of the target HTML template.
[0086] Optionally, the prompt information may be in various forms such as text, voice, image, video, etc. This embodiment does not limit the form of the prompt information.
[0087] Afterwards, if the user triggers an update instruction according to the prompt information, the template service module updates the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator of the target HTML template in response to the update instruction triggered by the user according to the prompt information.
[0088] In this embodiment, the template service module of the back-end server automatically determines whether the target HTML template hosted in the source server is updated, and when the target HTML template is updated, a prompt message indicating that the target HTML template corresponding to the uniform resource locator of the target HTML template is updated is output, so that the user can conveniently determine whether to update the local target HTML template in time. For example, when the user believes that the updated target HTML template is unsafe or unstable, the update of the target HTML template may not be triggered, thereby taking into account the timeliness, security and stability of the update of the target HTML template at the same time.
[0089] The above describes the backend management process of the target HTML template in the template processing method provided in the embodiment of the present invention. The following describes the process of the front end obtaining the target HTML template from the local computer in conjunction with a specific embodiment.
[0090] Figure 4 A flowchart of another HTML template processing method provided by an embodiment of the present invention, such as Figure 4 As shown, the following steps may be included:
[0091] 401. In response to a target HTML template being uploaded to a source server of a content distribution network, a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server are obtained.
[0092] 402. Establish a mapping relationship between the template identifier of the target HTML template and the uniform resource locator.
[0093] 403. In response to the establishment of the mapping relationship, download the target HTML template from the source server to the local computer.
[0094] 404. In response to the update of the target HTML template corresponding to the uniform resource locator, the locally stored target HTML template is updated to the HTML template currently corresponding to the uniform resource locator.
[0095] 405. Receive the template service request sent by the front end.
[0096] 406. According to the template identifier of the target HTML template included in the template service request, the locally stored target HTML is sent to the front end, so that the front end constructs a web page according to the target HTML template.
[0097] The specific implementation process of step 401 to step 404 may refer to the aforementioned embodiment and will not be described in detail in this embodiment.
[0098] For ease of understanding, combined Figure 5 To explain, Figure 5 A schematic diagram of a scenario for obtaining a target HTML template provided by an embodiment of the present invention. Figure 5 As shown, first, the user's browser or mobile terminal device obtains the IP address of the server corresponding to the domain name information of the website to be visited input by the user through the Domain Name System (DNS), that is, the IP address of the back-end server; then, a service request is sent to the back-end server of the IP address through the browser or mobile terminal device, and the back-end server performs corresponding processing operations after receiving the service request.
[0099] The service request includes a template service request and a business service request, and the template service request includes a template identifier of a target HTML template. In the specific implementation process, a gateway can be configured in the browser or mobile terminal device and the backend server to determine whether the service request is a template service request or a business service request, for example: according to the routing characteristics corresponding to the template service request and the business service request, it is determined whether the service request is a template service request or a business service request.
[0100] If the service request is a business service request, such as a database access request, the gateway forwards the business service request to the business service module so that the business service module processes the business service request and forwards the response result of the business service request to the browser or mobile terminal device through the gateway.
[0101] If the service request is a template service request, the gateway forwards the template service request to the template service module, and the template service module sends the locally stored target HTML to the front end according to the template identifier of the target HTML template included in the template service request, so that the front end builds a web page according to the target HTML template.
[0102] In this embodiment, by setting a template service module and a business processing module in the back-end server, separation of front-end HTML template management and back-end business processing is achieved, thereby improving the management efficiency of HTML templates.
[0103] The following will describe in detail the HTML template processing device of one or more embodiments of the present invention. Those skilled in the art will appreciate that these devices can be configured using commercially available hardware components through the steps taught in this solution.
[0104] Figure 6 A schematic diagram of the structure of an HTML template processing device provided by an embodiment of the present invention is shown in FIG. Figure 5 As shown, the device is applied to a template service module in a backend server, and includes: an acquisition unit 11, a processing unit 12, and a template management unit 13.
[0105] The acquisition unit 11 is configured to acquire a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server in response to the target HTML template being uploaded to the source server of the content distribution network.
[0106] The processing unit 12 is used to establish a mapping relationship between the template identifier and the uniform resource locator.
[0107] The template management unit 13 is used to download the target HTML template from the source server to the local in response to the establishment of the mapping relationship, so that the front end can obtain the target HTML template from the local; in response to the update of the target HTML template corresponding to the uniform resource locator, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator.
[0108] Optionally, the template management unit 13 is further used to receive a template service request sent by the front end; according to the template identifier of the target HTML template included in the template service request, send the locally stored target HTML to the front end so that the front end constructs a web page according to the target HTML template.
[0109] Optionally, the template management unit 13 is specifically used to obtain the HTML template currently corresponding to the uniform resource locator; determine whether the HTML template currently corresponding to the uniform resource locator is consistent with the target HTML template stored locally; if inconsistent, update the target HTML template stored locally to the HTML template currently corresponding to the uniform resource locator.
[0110] Optionally, the template management unit 13 is further specifically used to output a prompt message that the target HTML template corresponding to the uniform resource locator has been updated if there is inconsistency; in response to an update instruction triggered by the prompt message, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator.
[0111] Optionally, the acquisition unit 11 is also used to generate an HTML template management interface; send the HTML template management interface to the front end so as to display the HTML template management interface through the front end; and obtain the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server according to the user's configuration operations in the HTML template management interface.
[0112] Figure 6 The device shown can execute the steps introduced in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.
[0113] In one possible design, the above Figure 6 The structure of the HTML template processing device shown can be implemented as an electronic device, such as Figure 7As shown, the electronic device may include: a memory 21, a processor 22, and a communication interface 23. The memory 21 stores executable codes, and when the executable codes are executed by the processor 22, the processor 22 can at least implement the HTML template processing method provided in the above embodiments.
[0114] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the HTML template processing method provided in the aforementioned embodiment.
[0115] An embodiment of the present invention provides a computer program product, including: a computer program, when the computer program is executed by a processor of an electronic device, the processor is caused to execute the HTML template processing method provided in the above embodiment.
[0116] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0117] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for processing HTML templates, characterized in that: The template service module applied to the backend server comprises: In response to a target HTML template being uploaded to a source server of a content distribution network, obtaining a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server, wherein the target HTML template includes source code for constructing a web page on a front end; Establishing a mapping relationship between the template identifier and the uniform resource locator; In response to the establishment of the mapping relationship, the target HTML template is downloaded from the source server to a local location, so that the front end can obtain the target HTML template from the local location; In response to the update of the target HTML template corresponding to the uniform resource locator, the locally stored target HTML template is updated to the HTML template currently corresponding to the uniform resource locator.
2. The method according to claim 1, characterized in that The method further comprises: Receive template service requests sent by the front end; According to the template identifier of the target HTML template included in the template service request, the locally stored target HTML is sent to the front end, so that the front end constructs a web page according to the target HTML template.
3. The method according to claim 1, characterized in that In response to the update of the target HTML template corresponding to the uniform resource locator, updating the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator comprises: Get the HTML template currently corresponding to the uniform resource locator; Determine whether the HTML template currently corresponding to the uniform resource locator is consistent with the target HTML template stored locally; If they are inconsistent, the locally stored target HTML template is updated to the HTML template currently corresponding to the uniform resource locator.
4. The method according to claim 3, characterized in that The method further comprises: If they are inconsistent, outputting prompt information that the target HTML template corresponding to the uniform resource locator is updated; In response to an update instruction triggered by the prompt information, the locally stored target HTML template is updated to an HTML template currently corresponding to the uniform resource locator.
5. The method according to claim 1, characterized in that The step of obtaining the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server includes: Generate HTML template management interface; Sending the HTML template management interface to the front end so as to display the HTML template management interface through the front end; According to the configuration operation of the user in the HTML template management interface, the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server are obtained.
6. An HTML template processing device, characterized in that: A template service module applied to a backend server, the device comprising: an acquisition unit, configured to acquire, in response to the target HTML template being uploaded to a source server of a content distribution network, a template identifier of the target HTML template and a uniform resource locator of the target HTML template on the source server; A processing unit, configured to establish a mapping relationship between the template identifier and the uniform resource locator; A template management unit is used to download the target HTML template from the source server to a local computer in response to the establishment of the mapping relationship, so that the front end can obtain the target HTML template from the local computer; in response to the update of the target HTML template corresponding to the uniform resource locator, update the locally stored target HTML template to the HTML template currently corresponding to the uniform resource locator.
7. A backend server, characterized in that: The back-end server comprises: The template service module is used for, in response to the target HTML template being uploaded to the source server of the content distribution network, obtaining the template identifier of the target HTML template and the uniform resource locator of the target HTML template on the source server; establishing a mapping relationship between the template identifier and the uniform resource locator; in response to the establishment of the mapping relationship, downloading the target HTML template from the source server to the local; in response to the update of the target HTML template corresponding to the uniform resource locator, updating the locally stored target HTML template to the HTML template corresponding to the current uniform resource locator; Business service module, used to execute business logic and database operations.
8. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the HTML template processing method as described in any one of claims 1 to 5.
9. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable codes, and when the executable codes are executed by a processor of an electronic device, the processor is caused to execute the HTML template processing method according to any one of claims 1 to 5.
10. A computer program product, characterized in that include: A computer program, when executed by a processor of an electronic device, causes the processor to execute the HTML template processing method according to any one of claims 1 to 5.
Citation Information
Cited By
Method and device for quickly realizing desktop service and storage medium
CN121691317A