Spaces:
Runtime error
Runtime error
feat: add example environment configuration and simplify main script
Browse files- .env.example +4 -0
- main.py +1 -23
.env.example
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Application Settings
|
| 2 |
+
APP_NAME=template-python
|
| 3 |
+
DEBUG=true
|
| 4 |
+
ENV=development
|
main.py
CHANGED
|
@@ -1,23 +1 @@
|
|
| 1 |
-
|
| 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!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|