Skip to content

Commit bf95909

Browse files
committed
remove streamlit
1 parent 5edaade commit bf95909

4 files changed

Lines changed: 93 additions & 131 deletions

File tree

src/sample/__main__.py

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,34 @@
1-
# sample/__main__.py
2-
3-
from . import __version__
4-
import sys
51
import logging
6-
import subprocess
72
from pathlib import Path
8-
import click
9-
10-
logging.basicConfig(level=logging.INFO)
11-
3+
from http.server import SimpleHTTPRequestHandler
4+
from socketserver import TCPServer
5+
import os
126

13-
@click.group(invoke_without_command=True)
14-
@click.option("--version", is_flag=True, help="Show the Sample version and exit.")
15-
@click.pass_context
16-
def cli(ctx, version):
17-
"""Sample command-line tools."""
18-
if version:
19-
click.echo(__version__)
20-
ctx.exit()
21-
22-
23-
@cli.command()
24-
def dev():
25-
"""Run the Sample Streamlit app."""
26-
main()
27-
28-
29-
@cli.command()
30-
def api():
31-
"""Run the Sample FastAPI backend."""
32-
from api.fast_api import start
33-
34-
start()
7+
__version__ = "0.1.0"
8+
PORT = 8000
359

3610

3711
def main():
38-
"""
39-
Entrypoint for the Streamlit 'dev' app.
40-
"""
4112
print("🏷️ Sample version:", __version__)
42-
logging.info("Starting sample dev script...")
13+
logging.info("Starting static HTML server...")
4314

44-
# Paths
45-
Sample_dir = Path(__file__).resolve().parent
46-
dev_root = Sample_dir.parent # src/
47-
wheel_root = Sample_dir.parent # same in wheel
15+
sample_dir = Path(__file__).resolve().parent.parent
4816

49-
# Add correct root to sys.path
50-
if "site-packages" in str(Sample_dir): # running from wheel
51-
if str(wheel_root) not in sys.path:
52-
sys.path.append(str(wheel_root))
53-
logging.info(f"Added wheel root to sys.path: {wheel_root}")
54-
else: # dev mode
55-
if str(dev_root) not in sys.path:
56-
sys.path.append(str(dev_root))
57-
logging.info(f"Added dev src root to sys.path: {dev_root}")
17+
if "site-packages" in str(sample_dir):
18+
root = sample_dir
19+
logging.info("Running from wheel")
20+
else:
21+
root = sample_dir.parent
22+
logging.info("Running in dev mode")
5823

59-
# Locate streamlit_app.py
60-
streamlit_app_path = Sample_dir / "streamlit_app.py"
61-
logging.info(f"Streamlit app path: {streamlit_app_path}")
24+
logging.info(f"Serving from root: {root}")
6225

63-
if not streamlit_app_path.exists():
64-
logging.error(f"Streamlit app not found at: {streamlit_app_path}")
65-
return
26+
os.chdir(root)
6627

67-
# Run Streamlit app
68-
python_path = sys.executable
69-
logging.info(f"Using Python executable: {python_path}")
70-
71-
subprocess.run(
72-
[
73-
python_path,
74-
"-m",
75-
"streamlit",
76-
"run",
77-
str(streamlit_app_path.resolve()),
78-
"--server.port",
79-
"8501",
80-
],
81-
check=True,
82-
)
28+
with TCPServer(("", PORT), SimpleHTTPRequestHandler) as httpd:
29+
print(f"🌐 Open http://localhost:{PORT}/templates/index.html")
30+
httpd.serve_forever()
8331

8432

8533
if __name__ == "__main__":
86-
cli()
34+
main()

src/sample/streamlit_app.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

templates/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Greeting Page</title>
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
10+
<body>
11+
12+
<header>
13+
<img src="../src/assets/images/logo.png" width="80">
14+
<h1>Welcome</h1>
15+
</header>
16+
17+
<p>This is a plain HTML greeting page.</p>
18+
19+
<nav>
20+
<a href="faq.html">FAQ</a>
21+
</nav>
22+
23+
</body>
24+
25+
</html>

templates/style.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* Reset basic styling */
2+
body {
3+
margin: 0;
4+
font-family: Arial, Helvetica, sans-serif;
5+
background-color: #f5f5f5;
6+
color: #333;
7+
}
8+
9+
/* Header styling */
10+
header {
11+
display: flex;
12+
align-items: center;
13+
gap: 15px;
14+
padding: 15px 25px;
15+
background-color: #1e1e2f;
16+
color: white;
17+
}
18+
19+
/* Logo */
20+
header img {
21+
border-radius: 8px;
22+
}
23+
24+
/* Heading */
25+
header h1 {
26+
margin: 0;
27+
font-size: 24px;
28+
}
29+
30+
/* Paragraph */
31+
p {
32+
padding: 20px 25px;
33+
font-size: 16px;
34+
}
35+
36+
/* Navigation */
37+
nav {
38+
padding: 0 25px 25px;
39+
}
40+
41+
nav a {
42+
text-decoration: none;
43+
color: #0066cc;
44+
font-weight: bold;
45+
}
46+
47+
nav a:hover {
48+
text-decoration: underline;
49+
}

0 commit comments

Comments
 (0)