Skip to content

Commit 9291077

Browse files
committed
feat: add example environment configuration and simplify main script
1 parent f7b0744 commit 9291077

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Application Settings
2+
APP_NAME=template-python
3+
DEBUG=true
4+
ENV=development

main.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1 @@
1-
import http.server
2-
import socketserver
3-
import os
4-
from dotenv import load_dotenv
5-
6-
# Load environment variables from .env file
7-
load_dotenv()
8-
9-
# Get PORT from environment variable or use default 8000
10-
PORT = int(os.getenv("PORT", 8000))
11-
12-
13-
class MyHandler(http.server.BaseHTTPRequestHandler):
14-
def do_GET(self):
15-
self.send_response(200)
16-
self.send_header("Content-type", "text/plain")
17-
self.end_headers()
18-
self.wfile.write(b"Hello, World!")
19-
20-
21-
with socketserver.TCPServer(("", PORT), MyHandler) as httpd:
22-
print(f"Serving at port {PORT}")
23-
httpd.serve_forever()
1+
print("Hello, World!")

0 commit comments

Comments
 (0)