- Database schema: tablets, users, loans (junction table) - CLI app: minimal_app.py - Web apps: app.py (Flask), simple_app.py (http.server) - Features: loan management, search, user loans view, project notes - Git structure: CONTRIBUTING.md, .gitignore Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
81 lines
No EOL
2.5 KiB
Python
81 lines
No EOL
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Basic HTTP server to serve the tablet management system
|
|
"""
|
|
|
|
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
|
import os
|
|
|
|
class MyHandler(SimpleHTTPRequestHandler):
|
|
def do_GET(self):
|
|
if self.path == '/':
|
|
self.path = '/index.html'
|
|
return super().do_GET()
|
|
|
|
def run_server():
|
|
port = 8080
|
|
server_address = ('', port)
|
|
httpd = HTTPServer(server_address, MyHandler)
|
|
|
|
# Create a simple index file if it doesn't exist
|
|
if not os.path.exists('index.html'):
|
|
with open('index.html', 'w') as f:
|
|
f.write('''<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Tablet Management System</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 40px; }
|
|
h1 { color: #4CAF50; }
|
|
.info { background: #f0f0f0; padding: 20px; border-radius: 5px; }
|
|
.command { background: #e0e0e0; padding: 10px; border-radius: 3px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Tablet Management System</h1>
|
|
|
|
<div class="info">
|
|
<h2>Welcome to the Tablet Management System!</h2>
|
|
<p>This system is running with a SQLite backend.</p>
|
|
|
|
<h3>Available Commands:</h3>
|
|
<ul>
|
|
<li><strong>Test the system:</strong> <code class="command">python3 test_app.py</code></li>
|
|
<li><strong>Run interactive mode:</strong> <code class="command">python3 minimal_app.py</code></li>
|
|
<li><strong>Check database:</strong> <code class="command">sqlite3 tablets.db</code></li>
|
|
</ul>
|
|
|
|
<h3>Current Status:</h3>
|
|
<p>✓ Database: tablets.db</p>
|
|
<p>✓ Web server: Running on port 8080</p>
|
|
<p>✓ System: Ready for use</p>
|
|
</div>
|
|
|
|
<h3>Quick Test Results:</h3>
|
|
<pre id="test-results">Running tests...</pre>
|
|
|
|
<script>
|
|
// Simple test to show the system is working
|
|
fetch('/test-db')
|
|
.then(response => response.text())
|
|
.then(data => {
|
|
document.getElementById('test-results').textContent = data;
|
|
})
|
|
.catch(error => {
|
|
document.getElementById('test-results').textContent = 'Database test: Error - ' + error;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>''')
|
|
|
|
print(f"Server running on http://localhost:{port}")
|
|
print("Serving current directory")
|
|
print("Press Ctrl+C to stop the server")
|
|
|
|
try:
|
|
httpd.serve_forever()
|
|
except KeyboardInterrupt:
|
|
print("\nServer stopped")
|
|
|
|
if __name__ == '__main__':
|
|
run_server() |