0

I have the following code:

@app.route('/famcall/Audio/AudioMng_PlayDTMF/<string:output_stream>/<string:dtmf>/<string:duration>/<string:gap>', methods=['GET'])
    def fam_audio_play_dtmf(output_stream, dtmf, duration, gap):
        params = [self.mapAudioOutputStream.business_to_tech(output_stream), dtmf, duration, gap]
        return self.call_fam_function_and_wait_response("AudioMng_PlayDTMF", params)

and I want to use the character # in my url because it´s a value that can be used for dtmf. Is there an encode function in python which can help me in this? Or should I forget this scenario?

0

2 Answers 2

1

You can use a replacement: replace # with %23.

Sign up to request clarification or add additional context in comments.

Comments

1

Use urllib.quote (Python 2) or urllib.parse.quote (Python 3) to escape your dtmf value or anything else that might contain reserved characters.

2 Comments

How can I use this with my code? I´ve used it like this and it doesn´t work: params = [self.mapAudioOutputStream.business_to_tech(output_stream), dtmf, duration, gap] data = quote(params)
@H.Avram - it takes one string, not a list. urllib.quote(dtmf). The point is that it covers all reserved characters, not just #. EG urllib.quote('foo#bar:baz') returns 'foo%23bar%3Abaz'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.