问题
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:
port 80 may be in use by another task, even if it crashed.
If you use say port 8080 you have to use
http://12.34.255.89:8080/Request/...
method='POST'
can run into protection issues and be unreliable in some cases.See that the route matches including things like
.html
来源:https://stackoverflow.com/questions/15010556/python-bottle-issues-when-accessed-externally