假设我将此作为URL
https://localhost/?username=john_small
,我想获取用户名并显示例如:
在PHP中,我可以做这样的事情
$username = $_GET['username']
然后显示我所做的事情
<?php echo $username;?>
现在在Java中,我也可以做类似的事情
String username = request.getParameters("username");
我应该显示它吗,我做类似
<% "Hello" + <%=username%>; %>
例如,现在我想在groovy中做同样的事情,我可以像在Java中一样使用相同的东西吗?我在这里迷失了想法
答案 0 :(得分:0)
我认为我回答这个问题的时间太晚了,因为我才有机会使用SOAP UI:
以下作品:
import os, re, shutil
import spotipy
import spotipy.util as util
import time
# Parameters
username = 'REDACTED'
client_id = 'REDACTED'
client_secret = 'REDACTED'
redirect_uri = 'http://localhost/'
scope = 'user-library-read'
playlist = '17gneMykp6L6O5R70wm0gE'
def show_tracks(tracks):
for i, item in enumerate(tracks['items']):
track = item['track']
myName = re.sub('[^A-Za-z0-9\ ]+', '', track['name'])
dirName = "/Users/pschorn/Songs/" + myName + ".app"
if os.path.exists(dirName):
continue
#shutil.rmtree(dirName)
os.mkdir(dirName)
os.mkdir(dirName + "/Contents")
with open(dirName + "/Contents/PkgInfo", "w+") as f:
f.write("APPL????")
os.mkdir(dirName + "/Contents/MacOS")
with open(dirName + "/Contents/MacOS/" + myName, "w+") as f:
f.write("#!/bin/bash\n")
f.write("osascript -e \'tell application \"Spotify\" to play track \"{}\"\'".format(track['uri']))
os.lchmod(dirName + "/Contents/MacOS/" + myName, 0o777)
myName = re.sub('\ ', '\\ ', myName)
# I've installed a third-party command-line utility that
# allows me to set the icon for applications.
# If there's a way to do this from python, let me know.
os.system(
'/usr/local/bin/fileicon set /Users/pschorn/Songs/' + myName + '.app /Users/pschorn/Code/PyCharmSupport/Icon.icns')
token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
if token:
sp = spotipy.Spotify(auth=token)
results = sp.user_playlist(username, playlist, fields="tracks,next")
tracks = results['tracks', offset=100]
show_tracks(tracks)
else:
print("Can't get token for", username)