Initial commit: Bookish Flask app for ebook conversion and reading
This commit is contained in:
commit
32245f76ac
20 files changed
+2388
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
from bookish import create_app
|
||||
|
||||
app = create_app()
|
||||
|
||||
|
||||
def find_free_port(preferred=5000):
|
||||
"""Trova una porta libera partendo da preferred."""
|
||||
for port in range(preferred, preferred + 100):
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
if s.connect_ex(("127.0.0.1", port)) != 0:
|
||||
return port
|
||||
# fallback: lascia che il sistema assegni una porta
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.bind(("", 0))
|
||||
return s.getsockname()[1]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
preferred = int(sys.argv[1]) if len(sys.argv) > 1 and sys.argv[1].isdigit() else 5000
|
||||
port = find_free_port(preferred)
|
||||
print(f"📚 Bookish avviato su http://0.0.0.0:{port}")
|
||||
app.run(host="0.0.0.0", port=port, debug=True)
|
||||
Reference in new issue
Block a user