GithubHelp home page GithubHelp logo

Comments (13)

ymyuuu avatar ymyuuu commented on August 15, 2024

from spurl-api.

licoba avatar licoba commented on August 15, 2024

没有TG账号……具体就是有个测试网速的需求,能不能用你的这个API,测试上传和下载的网速

from spurl-api.

ymyuuu avatar ymyuuu commented on August 15, 2024

没有TG账号……具体就是有个测试网速的需求,能不能用你的这个API,测试上传和下载的网速

合法就可以,我可以把源码发给你,你自己搭建也可以,用我的也没事,API非常稳定

from spurl-api.

licoba avatar licoba commented on August 15, 2024

没有TG账号……具体就是有个测试网速的需求,能不能用你的这个API,测试上传和下载的网速

合法就可以,我可以把源码发给你,你自己搭建也可以,用我的也没事,API非常稳定

好的!👌感谢

from spurl-api.

ymyuuu avatar ymyuuu commented on August 15, 2024

没有TG账号……具体就是有个测试网速的需求,能不能用你的这个API,测试上传和下载的网速

合法就可以,我可以把源码发给你,你自己搭建也可以,用我的也没事,API非常稳定

好的!👌感谢

哥们我问一嘴,你们公司多大带宽啊

from spurl-api.

licoba avatar licoba commented on August 15, 2024

没有TG账号……具体就是有个测试网速的需求,能不能用你的这个API,测试上传和下载的网速

合法就可以,我可以把源码发给你,你自己搭建也可以,用我的也没事,API非常稳定

好的!👌感谢

哥们我问一嘴,你们公司多大带宽啊

公司的带宽千兆,主要是如果发布到线上了,那就是全球的用户都会用上……现在的用户体量在20w左右

from spurl-api.

ymyuuu avatar ymyuuu commented on August 15, 2024

没有TG账号……具体就是有个测试网速的需求,能不能用你的这个API,测试上传和下载的网速

合法就可以,我可以把源码发给你,你自己搭建也可以,用我的也没事,API非常稳定

好的!👌感谢

哥们我问一嘴,你们公司多大带宽啊

公司的带宽千兆,主要是如果发布到线上了,那就是全球的用户都会用上……现在的用户体量在20w左右

我丢,你先试试吧,我看看顶不顶得住,不行的话再说

from spurl-api.

licoba avatar licoba commented on August 15, 2024

想了想还是不用你的了🤣我向公司申请弄个自己的测速服务器吧,这成本本来也该公司摊

from spurl-api.

ymyuuu avatar ymyuuu commented on August 15, 2024

想了想还是不用你的了🤣我向公司申请弄个自己的测速服务器吧,这成本本来也该公司摊

我给你一个轻量级源码,可以直接搭建在cf workers免费服务器上,你先试试够不够你用,每天100,000次请求

from spurl-api.

ymyuuu avatar ymyuuu commented on August 15, 2024

想了想还是不用你的了🤣我向公司申请弄个自己的测速服务器吧,这成本本来也该公司摊

// Add an event listener for the fetch event
addEventListener('fetch', event => {
	// Use the handleRequest function to handle the request
	event.respondWith(handleRequest(event.request))
})

// Asynchronous function to handle the request
async function handleRequest(request) {
	// Parse the pathname from the request URL
	const { pathname } = new URL(request.url)

	// If the request is for the root directory, return a JSON message
	if (pathname === '/') {
		return new Response(JSON.stringify({
			message: 'This API allows you to download a specified number of bytes. Use the format /<number> or /<number>kb/mb/gb.'
		}), {
			headers: {
				'Content-Type': 'application/json; charset=utf-8' // Set the response header to JSON, encoded in UTF-8
			}
		})
	}

	// Use a regular expression to match the number of bytes in the request path
	const match = pathname.match(/^\/(\d+)([kmg]?b)?$/i)
	// If the path is invalid, return an error response
	if (!match) {
		return new Response(JSON.stringify({
			error: 'Invalid request format. Please use /<number> or /<number>kb/mb/gb format.'
		}), {
			status: 400, // Set the HTTP status code to 400 (Bad Request)
			headers: {
				'Content-Type': 'application/json; charset=utf-8' // Set the response header to JSON, encoded in UTF-8
			}
		})
	}

	// Parse the first numeric part as an integer, representing the number of bytes
	let bytes = parseInt(match[1], 10)
	// Get the unit part and convert it to lowercase
	const unit = match[2] ? match[2].toLowerCase() : null

	// Convert the number of bytes based on the unit
	if (unit === 'kb') {
		bytes *= 1024 // If the unit is kb, multiply by 1024
	} else if (unit === 'mb') {
		bytes *= 1024 * 1024 // If the unit is mb, multiply by 1024 squared
	} else if (unit === 'gb') {
		bytes *= 1024 * 1024 * 1024 // If the unit is gb, multiply by 1024 cubed
	}

	// Construct the Cloudflare Speed Test URL
	const speedTestUrl = `http://speed.cloudflare.com/__down?bytes=${bytes}`
	// Make the request and return the response
	return fetch(speedTestUrl)
}

from spurl-api.

licoba avatar licoba commented on August 15, 2024

好的!感谢

from spurl-api.

ymyuuu avatar ymyuuu commented on August 15, 2024

好的!感谢

不客气

from spurl-api.

licoba avatar licoba commented on August 15, 2024

好的!感谢

不客气

我又来问问题了!我看到代码里面用的是cloudflare的服务,这个可以免费测试下载速度,那cloudflare有免费的api,可以测试上传速度吗? 谢谢🙏谢谢解答谢谢

from spurl-api.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.