Support for listening on random port and opening browser without delays
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start by reviewing the server startup path in livereload.server and the web.Application and Server references shown in the issue. Use the monkeypatch example to understand the requested random-port and browser-opening behavior. Done means the server supports these flows without delays and exposes enough startup hooks for subclassing or customization.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
I wanted to support opening a browser on a random local port, and got it working with a bit of monkeypatching:
server = make_server(…)
import tornado.web
import tornado.httpserver
import tornado.netutil
import webbrowser
class Application(tornado.web.Application):
def listen(self, *args, **kw):
sockets = tornado.netutil.bind_sockets(0, 'localhost')
server = tornado.httpserver.HTTPServer(self)
server.add_sockets(sockets)
pairs = []
for s in sockets:
pairs.append(s.getsockname()[:2])
pairs.sort()
host, port = pairs[0]
if ":" in host:
host = f"[{host}]"
url = f"http://{host}:{port}"
log.info("Listening on %s", url)
async def open_browser():
webbrowser.open_new_tab(url)
tornado.ioloop.IOLoop.current().add_callback(open_browser)
return server
# Monkey patch to be able to start servers in a smoother way that the
# defaults of livereload
import livereload.server
livereload.server.web.Application = Application
server.serve()
Integrating this in livereload seems to require some refactoring of how the server is started, and I didn't engage on it. I hope that my monkeypatched code can be a useful reference.
Ideally, I would have liked to be able to subclass Server or the Application used by server, and have enough hooks to intervene in the listening bit.
- Ngôn ngữ chính
- Python
- Star
- 1.1k
- Fork
- 149
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của lepture/python-livereload
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
lepture/python-livereload#159 · 3 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
lepture/python-livereload#288 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
lepture/python-livereload#283 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
lepture/python-livereload#282 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
lepture/python-livereload#279 ·
Tất cả issue của lepture/python-livereload
Issue tương tự
-
`burr` fails to start when the Python path has a space in itCó thể đã có người làm @enekoreto đã nhận hôm nay. Đang mởstatus/needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 5 ngày
-
gemini 出现了新的域名需要加入Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
debpalash/VoiceStudio#2903 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dagster-io/community-integrations#367 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
aws-samples/sample-per-model-bedrock#243 ·
Maintainer thường phản hồi trong vòng 1 ngày