I would like to display "Hello World" on the web page in Bottle.
仮想 Create a virtual environment
②Install Bottle
③Run the program (described below)
④Launch Server for Bottle Framework Development
⑤Listing on htto://localhost:8000/ and
Entering the URL part into the browser results in an error.
The following error was displayed in the command prompt:
C:\Users\****(real name)\Desktop\yasashiipython\pybotweb\lib\site-
packages\bottle.py:3468:
Deprecation Warning: Flags not at the start of the expression
US>"(?m)[urbURB]?(?:'((truncated)
Patterns = [re.comple(p%pattern_vars) for pin patterns]
C:\Users\****(real name)\Desktop\yasashiipython\pybotweb\env\lib\site-
packages\bottle.py:3468:
DeprecationWarning: Flags not at the start of the expression '\\[\\{(?:(?)
m)[urbURB'(truncated)]
patterns = [re.compile(p&pattern_vars) for pin patterns]
127.0.0.1 - [07/May/2018 22:2625] "GET/HTTP/1.1" 404720
127.0.0.1 - [07/May/2018 22:2625] "GET/favicon.ico HTTP/1.1" 404 742
sys:1 —ResourceWarning:unclosed<socket.socket fd = 360,
family=AddressFamily.AF_INET,type=Socketkind.SOCK_STREAM,proto=0,laddr=
('127.0.0.1', 8000)
Error on Browser
Error: 404 Not Found
Sorry, the requested URL 'http://localhost:8080/'caused an error:
from bottle import route, run
@route('/hello')
def hello():
return 'Hello World!'
run(host='localhost', port=8000, debug=True)
There was another error before this error appeared.
When I looked it up, it was an error that occurred when the machine name was a Japanese string, so
Changed machine name and rebooted as is.Error names are not included.
Attempted host name 8080,8000 but failed.
Windows 8.1 64-bit
Python 3.6.5
If you look at the log, the Bottle is working and the debugger is detecting access to the wrong URL.
127.0.0.1 - [07/May/2018 22:2625] "GET/HTTP/1.1" 404720
Duplicate with teratail answer, but if you write @route('/hello')
, you must specify /hello in the URL PATH.
Verify that Hello World!
appears at the following URL:
Alternatively, you can view Hello World!
in http://localhost:8000/ by rewriting to @route('/')
as follows:
from bottle import route, run
@route('/')
def hello():
return 'Hello World!'
run(host='localhost', port=8000, debug=True)
DeprecationWarning is a warning that code in the Bottle uses the features that you plan to decommission.
Experience has shown that the Bottle itself is still working in my environment.
© 2024 OneMinuteCode. All rights reserved.