Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

forward query to _ws_handler

Aperta
#609 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, python
Ambito
backend, web-dev

Direzione di ricerca

Inizia leggendo trame/tools/serve.py, in particolare _index_handler e _ws_handler, e analizza la costruzione dell’URL WebSocket generato in index-.....js. Verifica come il browser si connette a /ws e determina come la stringa di query debba arrivare a _ws_handler. Il lavoro è completato quando la query è disponibile lì per l’inizializzazione dell’app senza dipendere dal workaround condiviso self.queries.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I'd like to load different files based on the query string

Modiefied part of https://github.com/Kitware/trame/blob/master/trame/tools/serve.py :

    async def _index_handler(self, request):
        if request.query_string:
            print(request.query)
            return aiohttp.web.HTTPFound(f"index.html?{request.query_string}")
        return aiohttp.web.HTTPFound("index.html")

    async def _ws_handler(self, request):
            print(request.query)

The first print prints the query, the second doesn't. I'd need the information in the second part to use it for initializing the app, right?

Describe the solution you'd like

In the index-.....js i find

xr=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.hostname}:${window.location.port}${mr("/ws")}`;

I'd guess if we would add there the query string, it should be forwarded such the second print would also print it?

Describe alternatives you've considered

What I do right now as a workaround:

...
        self.queries = []

    async def _index_handler(self, request):
        if request.query_string:
            self.queries.append(request.query_string)
            return aiohttp.web.HTTPFound(f"index.html?{request.query_string}")
        return aiohttp.web.HTTPFound("index.html")

    async def _ws_handler(self, request):
        print(self.queries.pop())

Does more or less the job, but it's for sure not a solution

Lingua principale
Python
Stelle
705
Fork
88
Merge medio
1h 43m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Kitware/trame

Tutte le issue di Kitware/trame

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.