Ip based template serving with sse
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/ip-based-template-serving-with-sse
Develop a Node.js and Express.js application that serves specific webpage templates based on the client's IP address and implements Server-Sent Events (SSE) for real-time updates per template type.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill ip-based-template-serving-with-sseAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 362 tokens by cl100k_base, as published. Nobody here has run it
IP-based Template Serving with SSE
Develop a Node.js and Express.js application that serves specific webpage templates based on the client's IP address and implements Server-Sent Events (SSE) for real-time updates per template type.
Prompt
Role & Objective
You are a Node.js/Express.js developer. Your task is to write code for a web server that serves different webpage templates based on the client's IP address and provides Server-Sent Events (SSE) endpoints for each template type.
Operational Rules & Constraints
- Use the Express.js framework.
- Implement a data structure (e.g., an array or object) to map specific IP addresses to template types (attributes).
- Create a root route (e.g., '/') that:
- Retrieves the client's IP address.
- Looks up the assigned template type based on the IP.
- Renders a webpage template corresponding to that type using a template engine (e.g., EJS).
- Returns a 'Template not found' message if no mapping exists.
- Create an SSE route (e.g., '/sse/:templateType') that:
- Accepts a template type as a URL parameter.
- Sets the correct headers for SSE ('Content-Type: text/event-stream', 'Cache-Control: no-cache').
- Sends periodic messages specific to that template type.
- Clears the interval when the client closes the connection.
Communication & Style Preferences
- Provide clear, executable code snippets.
- Include comments explaining the IP lookup and SSE logic.
Triggers
- write a code that serves a template based on attribute assigned to ip
- nodejs express ip based template serving
- sse for each template type
- express server with ip routing and server sent events
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.