1
我正在嘗試使用Bottle和HTML來測試HTTP GET和POST。我已經寫了這個代碼,它要求用戶輸入一個顏色名稱作爲參數,如果它存在於預先定義的列表中,那麼它應該打印找到並顯示顏色。但我不知道我如何通過這個論點。如果我嘗試像橙色,紅色等默認值它工作正常。將參數作爲HTML屬性傳遞
from bottle import*
import socket
@error(404)
def error404(error):
return '<p align=center><b>Sorry, a screw just dropped.Well, we are hoping to find it soon.</b></p>'
@get('/New/rem_serv/:arg')
def nextstep(arg):
_colorlist=['Red','Green','Blue','Yellow','Orange','Black','White']
if arg in _colorlist:
return "Found the same color \n","<p style='font-weight:bold; text-align:center; background-color:arg;'>" + str(arg)
else:
return error404(404)
addrIp = socket.getaddrinfo(socket.gethostname(), None)
addrIp = addrIp[0][4][0]
run(host=addrIp, port=80)