html post values addition in bottle application
Question: I was trying to add two html form values transferred via post in a python
bottle application. Unfortunately it is just concatenating. I tried to convert
the inputs to int but then i get" Unhandled Exception Error".... This is my
code

    
    
    from bottle import get, post, request,default_app # or route
    import math
    
    @get('/login') # or @route('/login')
    def login():
        return '''
            <form action="/login" method="post">
                Number1: <input name="num1" type="number" />
                Number2: <input name="num2" type="number" />
                <input value="Add" type="submit" />
            </form>
        '''
    
    @post('/login') # or @route('/login', method='POST')
    def do_login():
    
        num1 = request.forms.get('num1')
        num2 = request.forms.get('num2')
    
        return num1+num2
    import os
    from bottle import TEMPLATE_PATH
    TEMPLATE_PATH.append(os.path.join(os.environ['OPENSHIFT_HOMEDIR'], 
        'runtime/repo/wsgi/views/')) 
    application=default_app()
    

If i type return (int)num1+(int)num2 unhandled exception error results.. Dont
know why.. Same is for type(),float() functions as well.


Answer: I think you just have to convert the return value to str, so try:

`return str(int(num1) + int(num2))`

