サーバーをCherrypyでプログラムし、Makoを使用しています。
サイトで作業するためのデータを含む 1 つの変数 (ファイル [json] の内容である json_data) がありました。
これらのパラメーターを変更するには、クエリ文字列を使用する必要があります
データ管理に関する私の作業を簡素化するため。
サーバーが開いているときに、サーバーの URL に変数 (json_data) が必要です。
( localhost:8100?=json_data?json_data=demo_title%24+Demo+title+%23+
) セパレーターの python を javascript に置き換えることを知っています。
サイトを開始するときに、変数 json_data を URL に追加したいのですが、どうすればよいですか?
情報:
Json_data=
demo_title%24+Demo+title+%23+proc1_script%24+script.sh+parameters+%23+proc1_chk_make%24+on+%23+outputp2_value%24++%23+demo_input_description%24+hola+mundo+%23+outputp4_visible%24+on+%23+outputp4_info%24++%23+inputdata1_max_pixels%24+1024000+%23+tag%24++%23+outputp1_id%24+nanana+%23+proc1_src_compresion%24+zip+%23+proc1_chk_cmake%24+off+%23+outputp3_description%24++%23+outputp3_value%24++%23+inputdata1_description%24+input+data+description+%23+inputp2_description%24+bien%3F+%23+inputp3_description%24+funciona+%23+proc1_cmake%24+D+CMAKE_BUILD_TYPE%3Astring%3DRelease++%23+outputp2_visible%24+on+%23+outputp3_visible%24+on+%23+outputp1_type%24+header+%23+inputp1_type%24+text+%23+demo_params_description%24+va+bien+%23+outputp1_description%24++%23+inputdata1_type%24+image2d
プログラムで更新
import cherrypy
import urllib
#import requests
class Root(object):
@cherrypy.expose
def index(self):
jsondict = [('foo', '1'), ('foo', '2')]
p = urllib.urlencode(jsondict)
#url = urllib.urlopen("http://localhost:8080?%s" % params)
#urlVar = 1
#urlVar2 = 2
#requests.get("localhost:8080/?", params =p)
raise cherrypy.HTTPRedirect("localhost:8080?" + params)
cherrypy.config.update({
'server.socketPort': 8080
})
cherrypy.quickstart(Root())