This guide explains how to set up a full-stack web interface for your PyEveryday project using a Next.js frontend and FastAPI backend. Users will be able to interact with your Python scripts through a clean UI — no need to clone or run anything locally.
[ Next.js Frontend ] ⇄ [ FastAPI Backend ] ⇄ [ Python Scripts ]
pyeveryday-web/
├── backend/
│ ├── main.py
│ ├── routers/
│ │ ├── utilities.py
│ │ └── ...
│ ├── scripts/ # Your existing scripts, refactored as functions
│ └── requirements.txt
│
├── frontend/
│ ├── pages/
│ │ ├── index.tsx
│ │ └── utilities/
│ │ └── currency-converter.tsx
│ └── utils/api.ts
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install fastapi uvicornscripts/currency_converter.py
def convert_currency(amount: float, from_currency: str, to_currency: str) -> float:
# Your logic here
return round(amount * 83.2, 2) # Dummy conversionrouters/utilities.py
from fastapi import APIRouter
from scripts.currency_converter import convert_currency
router = APIRouter()
@router.get("/currency-converter")
def currency_converter(amount: float, from_currency: str, to_currency: str):
result = convert_currency(amount, from_currency, to_currency)
return {"converted_amount": result}main.py
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from routers import utilities
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(utilities.router, prefix="/utilities")uvicorn main:app --reload --port 8000npx create-next-app@latest frontend
cd frontend
npm installpages/utilities/currency-converter.tsx
import { useState } from "react"
export default function CurrencyConverter() {
const [amount, setAmount] = useState("")
const [from, setFrom] = useState("USD")
const [to, setTo] = useState("INR")
const [result, setResult] = useState("")
const convert = async () => {
const res = await fetch(
\`http://localhost:8000/utilities/currency-converter?amount=\${amount}&from_currency=\${from}&to_currency=\${to}\`
)
const data = await res.json()
setResult(data.converted_amount)
}
return (
<div>
<h1>Currency Converter</h1>
<input type="number" value={amount} onChange={(e) => setAmount(e.target.value)} />
<input value={from} onChange={(e) => setFrom(e.target.value)} />
<input value={to} onChange={(e) => setTo(e.target.value)} />
<button onClick={convert}>Convert</button>
{result && <p>Result: {result}</p>}
</div>
)
}-
Backend (from
backend/):uvicorn main:app --reload --port 8000
-
Frontend (from
frontend/):npm run dev
Visit http://localhost:3000/utilities/currency-converter to try it!
- Use Pydantic in FastAPI for input validation
- Use Tailwind or Chakra UI in Next.js for a nice UI
- Use
dotenvfor secrets and environment configs - Deploy backend with Render, Railway or Fly.io
- Deploy frontend with Vercel or Netlify
- Add UI for all PyEveryday scripts
- Convert scripts to support both CLI and API calls
- Add user history tracking (optional DB)
- Add script explorer page
Happy Hacking! ⚙️🚀