Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

Notice removed Improve details by Community Bot
Bounty Ended with no winning answer by Community Bot
Notice added Improve details by Basj
Bounty Started worth 50 reputation by Basj
added 15 characters in body
Source Link
jonrsharpe
  • 123.4k
  • 31
  • 278
  • 489

Let's say I send a request with JavascriptJavaScript:

fetch("/query?q=" + encodeURIComponent("c'est un château? Yes & no!"));
fetch("/query?q=" + encodeURIComponent("c'est un château? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
 print(q)
app.run() 
from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
 print(q)
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding?

Note: In this example, the ? and & are correctly decoded, but the â is not: print(q) gives c'est un château? Yes & no!

Let's say I send a request with Javascript:

fetch("/query?q=" + encodeURIComponent("c'est un château? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
 print(q)
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding?

Note: In this example, the ? and & are correctly decoded, but the â is not: print(q) gives c'est un château? Yes & no!

Let's say I send a request with JavaScript:

fetch("/query?q=" + encodeURIComponent("c'est un château? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
 print(q)
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding? In this example, the ? and & are correctly decoded, but the â is not: print(q) gives c'est un château? Yes & no!

added 147 characters in body
Source Link
Basj
  • 47.6k
  • 113
  • 468
  • 819

Let's say I send a request with Javascript:

fetch("/query?q=" + encodeURIComponent("Is that"c'est aun questionchâteau? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
 print(q)
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding?

Note: In this example, the ? and & are correctly decoded, but the â is not: print(q) gives c'est un château? Yes & no!

Let's say I send a request with Javascript:

fetch("/query?q=" + encodeURIComponent("Is that a question? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding?

Let's say I send a request with Javascript:

fetch("/query?q=" + encodeURIComponent("c'est un château? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
 print(q)
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding?

Note: In this example, the ? and & are correctly decoded, but the â is not: print(q) gives c'est un château? Yes & no!

Source Link
Basj
  • 47.6k
  • 113
  • 468
  • 819

Parameter encoded with encodeURIComponent, how to get it in a Python Bottle server?

Let's say I send a request with Javascript:

fetch("/query?q=" + encodeURIComponent("Is that a question? Yes & no!"));

to a Python Bottle server:

from bottle import Bottle, request
app = Bottle("")
@app.route("/query")
def query():
 q = request.query.get("q") # how to decode it?
app.run() 

How to decode request.query.get("q") so that it extracts the encodeURIComponent encoding?

default

AltStyle によって変換されたページ (->オリジナル) /