让 AI 根据浏览器请求的路径,现场制作 HTML

101 天前
 HMYang33

这是我最近想到的一个有趣的想法,写一个后端对接到 AI ,用户发来 HTTP 请求,我把请求路径转告 AI ,让 AI 现场生成内容。

已经部署到服务器上了。随便来玩!

http://103.97.179.26/

http://103.97.179.26/404.html

http://103.97.179.26/如何制作番茄炒蛋.html

用的 deepseek-chat

提示词

const ask = `你是一个 HTTP server ,` +
`用户当前在使用 ${req.method} 方法,` +
`请求路径是 ${req.url} ,` +
`请你对此请求和路径写出对应的 html 文档,` +
`HTML 文档的 head 标签中必须包含一个 charset=utf-8 标签,` +
`样式只能写成行内样式,写在标签的 style 属性上!` +
`除了 html 内容外不要返回其他内容!` +
`并且 html 内最少要有一个超链接,` +
`路径必须是本站的绝对路径。`;
4778 次点击
所在节点    分享创造
60 条回复
MossFox
101 天前
好奇怪的点子,感觉加上缓存跟页面关联之后能搞出一个风格奇怪的网站,好玩,
居然还适配了流式输出…… 刚好 HTML 在浏览器端渲染时也支持补全关闭 tag ,未曾想过的效果。

对了,req.url 会漏 Query ,换成 req.originalUrl 可以带上 Query 塞给提示词,
这里面其实还可以把 UserAgent 也塞进去,让提示词里面暗示了是手机端的请求的话它生成出的风格也会有区别。
xiaopanzi
101 天前
有趣
sepit
101 天前
我曹这个挺有意思的,感觉仔细想想能做很多事儿
fingerxie
101 天前
有意思啊,感觉能衍生好多业务场景啊
irrigate2554
101 天前
怪怪的,但是有趣
zy0829
101 天前
一遇到图片就不行了
ssiitotoo
101 天前
想法很新颖。
HMYang33
101 天前
@zy0829 因为 deepseek 没有出图能力
emonc
101 天前
笑死。
ShundL
101 天前
有点儿意思,要是 AI 能生成快一些,有更有意思了。。。
RealApe
101 天前
有意思,个人玩玩挺有趣的。
HMYang33
101 天前
@ShundL 有生成速度快的 AI 推荐吗
zcf0508
101 天前
@HMYang33 groq 的 deepseek-r1-distill-llama-70b
yuhaiyang
101 天前
jybox
101 天前
这个创意挺有趣的,尤其是你要求它每个页面至少要有一个链接,这种感觉有点像在维基百科上随便点来点去,如果能再优化一下让页面内容更有趣或更有价值就好了。
zekeluii
101 天前
申請個 ssl 就更棒了
gaobh
101 天前
可以做个网页游戏
ty29022
101 天前
试试小游戏
```
You are a professional classic game remake generator. Your task is to create a complete HTML page containing a playable remake version of a classic game. The user will provide the name of a classic game, and you need to generate the entire game based on that input.

Here's the name of the classic game you need to remake:
{{GAME_NAME}}

Follow these instructions carefully to create the game:

1. Output Format:
- Generate a complete HTML document, including the DOCTYPE declaration.
- Write all CSS styles within <style> tags. Do not reference external CSS files.
- Write all JavaScript code within <script> tags. Do not reference external JS files.
- Avoid using external resources. Draw all graphical elements using CSS or Canvas.
- Ensure the page is playable on both mobile and desktop devices.
- The page must be self-contained. Users should be able to save it as an .html file and play it directly in a browser.

2. Content Requirements:
- Game Title: Display both the Chinese and English names of the game.
- Game Introduction: Write 1-2 paragraphs introducing the game's background story and gameplay.
- Playable Game:
1) Implement the core gameplay mechanics.
2) Include basic game logic (collision detection, scoring, life points, etc.).
3) Provide keyboard controls (arrow keys, spacebar, etc.).
4) Offer touch control buttons for mobile devices.
5) Include game start, pause, and restart functionality.
- Game Interface:
1) Score display
2) Life/health display
3) Level or progress display
4) Game status indicators (start, end, pause, etc.)
- Control Instructions: Clearly explain how to play the game.
- Game History: Briefly describe the game's development history and classic status.

3. Game Design Requirements:
- Maintain the core gameplay and unique features of the original game.
- Use pixel art or minimalist style for visual design.
- Implement a reasonable difficulty curve.
- Ensure smooth operation and quick response times.
- Include appropriate sound effects (optional, can be replaced with CSS animations).
- Create clear game visuals with easily recognizable elements.

4. Technical Requirements:
- Use Canvas for game rendering to ensure smooth frame rates.
- Implement the game loop using requestAnimationFrame.
- Create a complete game state management system (menu, in-game, pause, end).
- Properly handle keyboard and touch events.
- Optimize collision detection algorithms.
- Manage memory to avoid leaks.
- Use clear code structure with object-oriented or modular design.

5. UI/UX Requirements:
- Design responsively to adapt to different screen sizes.
- Create an intuitive user interface that's easy to understand.
- Provide clear visual feedback (score changes, life changes, etc.).
- Layout game control buttons logically (for mobile).
- Use modern CSS effects to enhance visual experience.
- Ensure short loading times for immediate playability.

6. Game Functionality Requirements:
- Fully implement basic gameplay.
- Include a scoring system.
- Create multiple levels or increasing difficulty.
- Implement game over and restart logic.
- Record local high scores (using localStorage).
- Include pause and resume functionality.

7. Final Output:
Output the complete HTML code, starting with ```html and ending with ```. Ensure the code can run directly without any external dependencies.

Remember to adhere to all the requirements listed above while creating your game remake. Good luck!

```
Senorsen
101 天前
很有趣的创意!
建议:
1. 像 ls 们说的,考虑 User-Agent 以便手机端访问
2. 屏蔽 favicon.ico ,或者提供一个文件,否则浏览器每次请求都会浪费 token 让 AI 输出一个 Favicon Not Found
pusheax
101 天前
想到个应用场景:防止攻击者做 web 扫描。
同理,在主机上用 GPT 回复所有端口的请求,可以防止端口扫描。
按照端口号回复对应程序的报文,伪造出并未运行的应用,浪费攻击者的时间。
做蜜罐的厂商已经可以把这个功能加上了。现在的蜜罐都是手工模拟几个应用,工程量大,数量也少。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1137586

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX