Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
913 changes: 99 additions & 814 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ classifiers = [
]
dependencies = [
"fastapi (>=0.121.1,<0.122.0)",
"streamlit>=1.49.0",
"python-box (>=7.3.2,<8.0.0)",
"uvicorn (>=0.40.0,<0.41.0)",
"pymongo (>=4.15.5,<5.0.0)",
Expand Down
18 changes: 0 additions & 18 deletions src/features/greeting.py

This file was deleted.

89 changes: 19 additions & 70 deletions src/sample/__main__.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,35 @@
# sample/__main__.py

from . import __version__
import sys
import logging
import subprocess
from pathlib import Path
import click

logging.basicConfig(level=logging.INFO)


@click.group(invoke_without_command=True)
@click.option("--version", is_flag=True, help="Show the Sample version and exit.")
@click.pass_context
def cli(ctx, version):
"""Sample command-line tools."""
if version:
click.echo(__version__)
ctx.exit()

from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
import os

@cli.command()
def dev():
"""Run the Sample Streamlit app."""
main()


@cli.command()
def api():
"""Run the Sample FastAPI backend."""
from api.fast_api import start
from utils.constants import PORT
from . import __version__

start()


def main():
"""
Entrypoint for the Streamlit 'dev' app.
"""
print("🏷️ Sample version:", __version__)
logging.info("Starting sample dev script...")

# Paths
Sample_dir = Path(__file__).resolve().parent
dev_root = Sample_dir.parent # src/
wheel_root = Sample_dir.parent # same in wheel
logging.info("Starting static HTML server...")

# Add correct root to sys.path
if "site-packages" in str(Sample_dir): # running from wheel
if str(wheel_root) not in sys.path:
sys.path.append(str(wheel_root))
logging.info(f"Added wheel root to sys.path: {wheel_root}")
else: # dev mode
if str(dev_root) not in sys.path:
sys.path.append(str(dev_root))
logging.info(f"Added dev src root to sys.path: {dev_root}")
sample_dir = Path(__file__).resolve().parent.parent

# Locate streamlit_app.py
streamlit_app_path = Sample_dir / "streamlit_app.py"
logging.info(f"Streamlit app path: {streamlit_app_path}")
if "site-packages" in str(sample_dir):
root = sample_dir
logging.info("Running from wheel")
else:
root = sample_dir.parent
logging.info("Running in dev mode")

if not streamlit_app_path.exists():
logging.error(f"Streamlit app not found at: {streamlit_app_path}")
return
logging.info(f"Serving from root: {root}")

# Run Streamlit app
python_path = sys.executable
logging.info(f"Using Python executable: {python_path}")
os.chdir(root)

subprocess.run(
[
python_path,
"-m",
"streamlit",
"run",
str(streamlit_app_path.resolve()),
"--server.port",
"8501",
],
check=True,
)
with TCPServer(("", PORT), SimpleHTTPRequestHandler) as httpd:
print(f"🌐 Open http://localhost:{PORT}/templates/index.html")
httpd.serve_forever()


if __name__ == "__main__":
cli()
main()
60 changes: 0 additions & 60 deletions src/sample/streamlit_app.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
APP_TITLE = ":blue[Greeting Feature]"
DEFAULT_GREETING = "Hello"
FAQ_TITLE = "FAQs"

PORT = 8000
# --- Asset paths ---
PROJECT_ROOT = Path(__file__).parent.parent
ASSETS_DIR = PROJECT_ROOT / "assets" / "images"
Expand Down
2 changes: 1 addition & 1 deletion templates/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ <h1>Frequently Asked Questions</h1>
<p>This is a useful to start the development with pre-defined template and best practices and define folder
structure.</p>
</details>
</div>
</div>
25 changes: 25 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Greeting Page</title>
<link rel="stylesheet" href="style.css">
</head>

<body>

<header>
<img src="../src/assets/images/logo.png" width="80">
<h1>Welcome</h1>
</header>

<p>This is a plain HTML greeting page.</p>

<nav>
<a href="faq.html">FAQ</a>
</nav>

</body>

</html>
49 changes: 49 additions & 0 deletions templates/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Reset basic styling */
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
background-color: #f5f5f5;
color: #333;
}

/* Header styling */
header {
display: flex;
align-items: center;
gap: 15px;
padding: 15px 25px;
background-color: #1e1e2f;
color: white;
}

/* Logo */
header img {
border-radius: 8px;
}

/* Heading */
header h1 {
margin: 0;
font-size: 24px;
}

/* Paragraph */
p {
padding: 20px 25px;
font-size: 16px;
}

/* Navigation */
nav {
padding: 0 25px 25px;
}

nav a {
text-decoration: none;
color: #0066cc;
font-weight: bold;
}

nav a:hover {
text-decoration: underline;
}