🖥️

Creating Websites with Python and AI

Apr 28, 2025

Lecture Notes: Building Deepsite with Python

Introduction

  • Presenter: Marlene
  • Topic: Building "Deepsite" application using Python
  • Platform Highlighted: Hugging Face for open-source AI and machine learning projects
  • Target: Convert a Typescript project to Python

Deepsite Overview

  • Functionality: Generates website UI using HTML, JS, and CSS
  • Tool Used: Deepseek R1
  • Source: Found on Hugging Face Spaces, which is a platform for sharing projects
  • Purpose: Simplifies the process of creating web applications

Project Setup

Steps to Access the Project

  1. Locate Deepsite on Hugging Face Spaces:
    • Explore example websites built using the application.
  2. GitHub Repository:
    • Access the code via the files tab which links to GitHub.
    • Option to clone repository but not necessary for this tutorial.

Choosing Python over Typescript

  • Main Focus: AI code in service.js
  • Key Element: System prompt that guides HTML, CSS, and JavaScript usage.
  • Prompt Instructions:
    • Use of Tailwind CSS
    • Single HTML file

Implementation in Python

Environment Setup

  • Tools Needed:
    • VS Code
    • Python Jupyter Notebook
  • Dependencies:
    • requirements.txt includes langchain Azure AI and Python
    • Install using pip install -r requirements.txt

Code Structure

  1. System Prompt Setup:
    • Define Python string for the system prompt
  2. Dependencies:
    • Import necessary packages from Langchain and Azure AI.
  3. Initialize Deepseek Model:
    • Provide Azure AI endpoint and API key.
    • Configure model settings, such as temperature and max tokens for creativity.

Function Implementation

  • Function Name: stream_response
  • Objective: Process prompt to generate website code.
  • Steps:
    • Define messages (system and human prompts)
    • Utilize Langchain to stream model responses
    • Capture generated HTML code
    • Output includes code and a description of the generated app

Testing and Results

  • Example Prompt: "Create a simple purple to-do list."
  • Output Verification:
    • Run code to see HTML output
    • Example result: "Stylish purple-themed to-do list app"

Further Development

Creating a Flask Application

  • Approach: Use Copilot and agent mode for vibe coding
  • Outcome: Python-based application with a similar UI to Deepsite
  • Deployment: Option to deploy applications with custom names

Conclusion

  • Reflection:
    • Ease of generating functional web apps with minimal code
    • Potential in AI-driven UI generation
  • Final Thoughts: Encouragement to explore these technologies and additional resources in the video description

Additional Resources

  • Links to connect with Marlene's previous videos
  • Encourage engagement and feedback through comments and subscriptions