Python Bottle Issues when Accessed Externally

给你一囗甜甜゛ 提交于 2019-12-11 05:02:53

问题


So I am using the bottle module for python to listen for requests on my server. I've done all the testing locally and now that it has come time for deployment, I can't get it to run on my server.

from bottle import route, get, post, request, Bottle, run, template

@route('/Request/<UniqueID>') #Build Temporary Webpage
def login_form(UniqueID):
    return '''<form method="POST" action="/SLR_Creation">
                ID: <input name="UID" type="text" value="''' +UniqueID+ '''" /><br />
                Scale: <input name="Scale" type="text" value="10000"/><br />
                <input type="submit" value="CLick here to create report"/>
              </form>'''

@route('/<UniqueID>', method='POST') # Return
def PHPH_Script(UniqueID):
     # Big long script to create a report
     return '''<p>The report has been created. Click this button to access it.<br /></p>
            <form action="''' + WebLocation +'''.html">
                <input type="submit" value="CLick here to access report">
            </form>'''    

# Create and Run Page
#run(host='localhost', port=8080)
run(host='12.34.255.89', port=80) # This is not my actually IP Address.

Now that last line of code is what keeps giving me an error of: error: [Errno 10049] The requested address is not valid in its context. Now if I use the commented out line, it works like a charm.

I know that my IP is correct and the port is open, so does anyone have any idea of what my issue is here?


回答1:


Maybe several issues:

  1. port 80 may be in use by another task, even if it crashed.

  2. If you use say port 8080 you have to use

    http://12.34.255.89:8080/Request/...

  3. method='POST' can run into protection issues and be unreliable in some cases.

  4. See that the route matches including things like .html



来源:https://stackoverflow.com/questions/15010556/python-bottle-issues-when-accessed-externally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!