Giter Site home page Giter Site logo

xingxingc / screenshot-to-code Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abi/screenshot-to-code

0.0 0.0 0.0 2.05 MB

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Home Page: https://screenshottocode.com

License: MIT License

Shell 0.07% JavaScript 0.95% Python 55.19% TypeScript 42.04% CSS 0.80% HTML 0.64% Dockerfile 0.31%

screenshot-to-code's Introduction

screenshot-to-code

A simple tool to convert screenshots, mockups and Figma designs into clean, functional code using AI.

Youtube.Clone.mp4

Supported stacks:

  • HTML + Tailwind
  • React + Tailwind
  • Vue + Tailwind
  • Bootstrap
  • Ionic + Tailwind
  • SVG

Supported AI models:

  • GPT-4 Vision
  • Claude 3 Sonnet (faster, and on par or better than GPT-4 vision for many inputs)
  • DALL-E 3 for image generation

See the Examples section below for more demos.

We also just added experimental support for taking a video/screen recording of a website in action and turning that into a functional prototype.

google in app quick 3

Learn more about video here.

Follow me on Twitter for updates.

๐Ÿš€ Try It Out!

๐Ÿ†• Try it live on the hosted version (bring your own OpenAI key - your key must have access to GPT-4 Vision. See FAQ section below for details). Or see Getting Started below for local install instructions.

๐Ÿ›  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 or an Anthropic key if you want to use Claude Sonnet, or for experimental video support.

Run the backend (I use Poetry for package management - pip install poetry if you don't have it):

cd backend
echo "OPENAI_API_KEY=sk-your-key" > .env
poetry install
poetry shell
poetry run uvicorn main:app --reload --port 7001

If you want to use Anthropic, add the ANTHROPIC_API_KEY to backend/.env with your API key from Anthropic.

Run the frontend:

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):

MOCK=true poetry run uvicorn main:app --reload --port 7001

Docker

If you have Docker installed on your system, in the root directory, run:

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. 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 configure an OpenAI proxy? - 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
  • How can I update the backend host that my front-end connects to? - Configure VITE_HTTP_BACKEND_URL and VITE_WS_BACKEND_URL in front/.env.local For example, set VITE_HTTP_BACKEND_URL=http://124.10.20.1:7001
  • How can I provide feedback? For feedback, feature requests and bug reports, open an issue or ping me on Twitter.

๐Ÿ“š Examples

NYTimes

Original Replica
Screenshot 2023-11-20 at 12 54 03 PM Screenshot 2023-11-20 at 12 59 56 PM

Instagram page (with not Taylor Swift pics)

instagram.taylor.swift.take.1.mp4

Hacker News but it gets the colors wrong at first so we nudge it

hacker.news.with.edits.mp4

๐ŸŒ Hosted Version

๐Ÿ†• Try it here (bring your own OpenAI key - your key must have access to GPT-4 Vision. See FAQ section for details). Or see Getting Started for local install instructions.

"Buy Me A Coffee"

screenshot-to-code's People

Contributors

abi avatar alexlloyd0 avatar clean99 avatar dialmedu avatar eltociear avatar guspan-tanadi avatar hakeemmidan avatar jonathan-adly avatar justindhillon avatar kachbit avatar nothing1024 avatar ntsd avatar pranshugupta54 avatar samya123456 avatar steadily-worked avatar sweep-ai[bot] avatar vagusx avatar zweertsk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.