# screenshot-to-code
This simple app converts a screenshot to code (HTML/Tailwind CSS, or React or Bootstrap). It uses GPT-4 Vision to generate the code and DALL-E 3 to generate similar-looking images. You can now also enter a URL to clone a live website!
https://github.com/abi/screenshot-to-code/assets/23818/6cebadae-2fe3-4986-ac6a-8fb9db030045
See the [Examples](#-examples) section below for more demos.
## ð Try It Out!
ð [Try it here](https://screenshottocode.com) (bring your own OpenAI key - **your key must have access to GPT-4 Vision. See [FAQ](#%EF%B8%8F-faqs) section below for details**). Or see [Getting Started](#-getting-started) below for local install instructions.
## ð Recent Updates
- Dec 11 - Start a new project from existing code (allows you to come back to an older project)
- Dec 7 - ð¥ ð¥ ð¥ View a history of your edits, and branch off them
- Nov 30 - Dark mode, output code in Ionic (thanks [@dialmedu](https://github.com/dialmedu)), set OpenAI base URL
- Nov 28 - ð¥ ð¥ ð¥ Customize your stack: React or Bootstrap or TailwindCSS
- Nov 23 - Send in a screenshot of the current replicated version (sometimes improves quality of subsequent generations)
- Nov 21 - Edit code in the code editor and preview changes live thanks to [@clean99](https://github.com/clean99)
- Nov 20 - Paste in a URL to screenshot and clone (requires [ScreenshotOne free API key](https://screenshotone.com?via=screenshot-to-code))
- Nov 19 - Support for dark/light code editor theme - thanks [@kachbit](https://github.com/kachbit)
- Nov 16 - Added a setting to disable DALL-E image generation if you don't need that
- Nov 16 - View code directly within the app
- Nov 15 - You can now instruct the AI to update the code as you wish. It is helpful if the AI messed up some styles or missed a section.
## ð Getting Started
The app has a React/Vite frontend and a FastAPI backend. You will need an OpenAI API key with access to the GPT-4 Vision API.
Run the backend (I use Poetry for package management - `pip install poetry` if you don't have it):
```bash
cd backend
echo "OPENAI_API_KEY=sk-your-key" > .env
poetry install
poetry shell
poetry run uvicorn main:app --reload --port 7001
```
Run the frontend:
```bash
cd frontend
yarn
yarn dev
```
Open http://localhost:5173 to use the app.
If you prefer to run the backend on a different port, update VITE_WS_BACKEND_URL in `frontend/.env.local`
For debugging purposes, if you don't want to waste GPT4-Vision credits, you can run the backend in mock mode (which streams a pre-recorded response):
```bash
MOCK=true poetry run uvicorn main:app --reload --port 7001
```
## Configuration
* You can configure the OpenAI base URL if you need to use a proxy: Set OPENAI_BASE_URL in the `backend/.env` or directly in the UI in the settings dialog
## Docker
If you have Docker installed on your system, in the root directory, run:
```bash
echo "OPENAI_API_KEY=sk-your-key" > .env
docker-compose up -d --build
```
The app will be up and running at http://localhost:5173. Note that you can't develop the application with this setup as the file changes won't trigger a rebuild.
## ðââï¸ FAQs
- **I'm running into an error when setting up the backend. How can I fix it?** [Try this](https://github.com/abi/screenshot-to-code/issues/3#issuecomment-1814777959). If that still doesn't work, open an issue.
- **How do I get an OpenAI API key?** See https://github.com/abi/screenshot-to-code/blob/main/Troubleshooting.md
- **How can I provide feedback?** For feedback, feature requests and bug reports, open an issue or ping me on [Twitter](https://twitter.com/_abi_).
## ð Examples
**NYTimes**
| Original | Replica |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <img width="1238" alt="Screenshot 2023-11-20 at 12 54 03 PM" src="https://github.com/abi/screenshot-to-code/assets/23818/3b644dfa-9ca6-4148-84a7-3405b6671922"> | <img width="1414" alt="Screenshot 2023-11-20 at 12 59 56 PM" src="https://github.com/abi/screenshot-to-code/assets/23818/26201c9f-1a28-4f35-a3b1-1f04e2b8ce2a"> |
**Instagram page (with not Taylor Swift pics)**
https://github.com/abi/screenshot-to-code/assets/23818/503eb86a-356e-4dfc-926a-dabdb1ac7ba1
**Hacker News** but it gets the colors wrong at first so we nudge it
https://github.com/abi/screenshot-to-code/assets/23818/3fec0f77-44e8-4fb3-a769-ac7410315e5d
## ð Hosted Version
ð [Try it here](https://screenshottocode.com) (bring your own OpenAI key - **your key must have access to GPT-4 Vision. See [FAQ](#%EF%B8%8F-faqs) section for details**). Or see [Getting Started](#-getting-started) for local install instructions.
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/abiraja)
没有合适的资源?快使用搜索试试~ 我知道了~
屏幕截图转代码生成:放入屏幕截图并将其转换为干净的代码(HTML/Tailwind/Rect)
共96个文件
tsx:37个
py:18个
ts:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 117 浏览量
2023-12-25
09:22:17
上传
评论
收藏 484KB ZIP 举报
温馨提示
放入屏幕截图并将其转换为干净的代码(HTML/Tailwind/Rect) 这个简单的应用程序将屏幕截图转换为代码(HTML/Tailwind-CSS,或React或Bootstrap)。它使用GPT-4 Vision生成代码,并使用DALL-E 3生成外观相似的图像。您现在也可以输入URL来克隆实时网站!
资源推荐
资源详情
资源评论
收起资源包目录
screenshot-to-code-main.zip (96个子文件)
screenshot-to-code-main
.vscode
settings.json 51B
design-docs.md 192B
sweep.yaml 2KB
backend
utils.py 1KB
mock_llm.py 11KB
eval.py 2KB
main.py 614B
poetry.lock 33KB
imported_code_prompts.py 6KB
eval_utils.py 228B
screenshot_system_prompts.py 9KB
image_generation.py 4KB
access_token.py 621B
Dockerfile 473B
routes
screenshot.py 2KB
home.py 324B
generate_code.py 10KB
evals.py 1KB
pyproject.toml 471B
.gitignore 3KB
llm.py 1KB
README.md 31B
prompts.py 3KB
test_prompts.py 18KB
build.sh 207B
eval_config.py 22B
config.py 494B
.gitattributes 66B
LICENSE 1KB
frontend
yarn.lock 164KB
tsconfig.node.json 213B
tailwind.config.js 2KB
components.json 323B
.env.example 40B
src
lib
utils.ts 267B
main.tsx 644B
types.ts 995B
constants.ts 48B
App.tsx 17KB
generateCode.ts 2KB
config.ts 451B
components
SettingsDialog.tsx 7KB
OutputSettingsSection.tsx 4KB
OnboardingNote.tsx 936B
history
HistoryDisplay.tsx 3KB
utils.test.ts 5KB
history_types.ts 769B
utils.ts 2KB
CodeTab.tsx 3KB
ImportCodeSection.tsx 2KB
CodePreview.tsx 545B
Spinner.tsx 1KB
evals
EvalsPage.tsx 2KB
RatingPicker.tsx 945B
ImageUpload.tsx 4KB
TermsOfServiceDialog.tsx 3KB
PicoBadge.tsx 1KB
CodeMirror.tsx 2KB
Preview.tsx 1KB
ui
separator.tsx 756B
dialog.tsx 4KB
collapsible.tsx 315B
progress.tsx 778B
hover-card.tsx 1KB
badge.tsx 1KB
input.tsx 801B
popover.tsx 1KB
scroll-area.tsx 2KB
select.tsx 6KB
alert-dialog.tsx 4KB
button.tsx 2KB
checkbox.tsx 1KB
label.tsx 710B
switch.tsx 1KB
tabs.tsx 2KB
accordion.tsx 2KB
textarea.tsx 732B
UrlInputSection.tsx 2KB
settings
AccessCodeSection.tsx 4KB
vite-env.d.ts 38B
hooks
useThrottle.ts 939B
usePersistedState.ts 544B
index.css 2KB
package.json 2KB
public
brand
twitter-summary-card.png 330KB
Dockerfile 405B
.eslintrc.cjs 436B
vite.config.ts 842B
index.html 2KB
.gitignore 272B
tsconfig.json 673B
postcss.config.js 80B
docker-compose.yml 609B
Troubleshooting.md 1KB
.gitignore 178B
README.md 5KB
共 96 条
- 1
资源评论
UnknownToKnown
- 粉丝: 1w+
- 资源: 773
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功