即http://www.somesite.com/subject?page=3
如果使用查询字符串来控制分页,搜索引擎不是只能索引第一页(即没有查询字符串的页面)吗?这通常是我看到的分页完成的方式,但我想知道是否有更好的搜索引擎索引方法?
无法构造包含 3 个参数的 URL。在网络上没有找到任何合适的现有示例。
路由器.py
router = routers.SimpleRouter()
router.register(r'reservation(?P<param1>)', ReservationViewSet, 'reservation')
Run Code Online (Sandbox Code Playgroud)
这适用于一个参数。添加另外两个参数来解析 URL 的正确语法是什么:
http://127.0.0.1:8000/api/general/reservation?enterprise=4&start=01-01-2015&end=01-31-2016
?
谢谢!
我有以下路由,适用于 invokation /api/demo/info/34。
[Route("api/demo")]
public class Demo : Controller
{
[HttpGet("Info/{x}")]
public JsonResult GetInfos(string x) { ... }
}
Run Code Online (Sandbox Code Playgroud)
现在,我想传递一个查询字符串来选择 ID,如下所示:/api/demo/info?x=34。我应该如何重新表述该属性?
当我尝试输入 时[HttpGet("Info?x={x}")],错误消息表明问号在那里无效。我想通过归因方法来解决它,并且从默认映射进行路由不是一个选项。
在 GET 上将具有多个值的参数作为查询字符串传递是很常见的:
http://server/status?stat=a&stat=b
Run Code Online (Sandbox Code Playgroud)
如何使用 JS 中的 axios 库创建这种类型的查询字符串?创建一个对象,其中参数名称是键,值是多个值的数组,从而创建一个查询字符串:
http://server/status?stat[]=a&stat[]=b
Run Code Online (Sandbox Code Playgroud)
这与服务器期望的格式不正确。这可以在 axios 中完成吗?
一些在线文章说,URL 中的querystring和没有标准hash,但我们正在关注继续发生的事情。所以,我的问题是在同一个 URL 中同时使用查询字符串和哈希值的更好方法是什么。
我认为的问题是,如果哈希跟随查询字符串,它可以成为某些查询字符串数据的值,如果查询字符串跟随哈希,则整个查询字符串可能成为哈希。那么,我应该遵循什么顺序?
我有 .net core 2.2 web api 我将它升级到“inProcess”,使用双前向斜杠调用此服务的客户端得到 404,当将其配置为“OutOfProcess”时,它工作得很好。有问题的调用示例:
https://mMYApiAddress.co/api/GetSomeData//3
当将它配置为“OutOfProcess”时,它工作得很好。
我希望我的 web api 能够在“inProcess”配置中工作,并且能够像以前一样使用双斜杠进行调用。
我正在使用 AWS Cognito 的托管 UI 进行用户登录。id 令牌作为 URL 的一部分返回,如https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-app-integration.html中所述。即,
您可以在响应中的 #idtoken= 参数后面找到 JSON Web 令牌 (JWT) 身份令牌。以下是隐式授予请求的示例响应。https://www.example.com/#id_token=123456789tokens123456789&expires_in=3600&token_type=承载
但是,将敏感数据放入查询字符串中被认为是一种不好的做法(HTTPS 查询字符串安全吗?)。AWS Cognito 是否支持更安全的返回 id 令牌的方式?
为什么需要使用字典并设置参数?例如lat,lng如下:
parameters = {
"lat": MY_LAT,
"lng": MY_LONG,
"formatted": 0
}
response = requests.get(url="https://api.sunrise-sunset.org/json", params=parameters)
Run Code Online (Sandbox Code Playgroud)
为什么我不能执行以下操作,例如输入纬度?
response = requests.get(url="https://api.sunrise-sunset.org/json", params=parameters, lat=MY_LAT)
Run Code Online (Sandbox Code Playgroud) 我有一个 API 端点,可以获取名称和描述参数(两者都是必需的)
createSomething(@RequestParam(value = "name") String name,@RequestParam(value = "description") String description)
Run Code Online (Sandbox Code Playgroud)
如果客户没有提供其中任何一个,他将收到 400 Bad Request
我有办法告诉客户缺少哪个字段吗?提供有关“错误请求”响应的更多信息
更新:请注意,这些参数必须是强制性的,因为我希望 OpenAPI 能够检测到这些参数是强制性的。因此,诸如“可选”和检查函数体内之类的解决方案并不是我想要的
此代码适用于 Flask
import requests
from flask import Flask,request,session,render_template, jsonify
import requests,time
from datetime import datetime,timedelta
app = Flask(__name__,template_folder='./')
@app.route('/')
def home():
return render_template("For_putting_lat_lon.html")
@app.route('/distance')
def check():
Latitude1 = request.args.get("Latitude1")
Latitude2 = request.args.get("Latitude2")
Longitude1 = request.args.get("Longitude1")
Longitude2 = request.args.get("Longitude2")
data = list()
result = Travel_distance(Latitude1, Longitude1, Latitude2, Longitude2,data)
if(result == 0):
return render_template("noavailable.html")
return render_template("For_posting_lat_lon.html",data = data)
def Travel_distance(Latitude1, Longitude1, Latitude2, Longitude2, data):
geolocator = Nominatim(user_agent="geoapiExercises")
location_name1 = geolocator.geocode(str(Latitude1)+", " +str(Longitude1))
location_name2 = geolocator.geocode(str(Latitude2)+", "+str(Longitude2))
req = requests.get(f"""http://router.project-osrm.org/route/v1/drive/{Longitude1},{Latitude1};{Longitude2},{Latitude2}?overview=false""") #car,bike,foot
route_1 = …Run Code Online (Sandbox Code Playgroud) query-string ×10
python ×3
c# ×2
javascript ×2
.net-core ×1
asp.net-core ×1
axios ×1
django ×1
fastapi ×1
get ×1
hash ×1
java ×1
pagination ×1
rest ×1
routes ×1
seo ×1
spring ×1
spring-boot ×1
url ×1