Note
It's designed as a debugger tool for package tzf, not production ready.
go install github.com/ringsaturn/tzf-server@latest
Please visit https://github.com/ringsaturn/tzf-server/releases to get latest release.
Install from Docker Hub
docker pull ringsaturn/tzf-server
Usage of tzf-server:
-disable-print-route
Disable Print Route
-hertz-prometheus-host-port string
Hertz Prometheus Host&Port (default "0.0.0.0:8090")
-hertz-prometheus-path string
Hertz Prometheus Path (default "/hertz")
-http-addr string
HTTP Host&Port (default "0.0.0.0:8080")
-path string
custom data
-prometheus-enable-go-coll
Enable Go Collector (default true)
-prometheus-host-port string
Prometheus Host&Port (default "0.0.0.0:2112")
-prometheus-path string
Prometheus Path (default "/metrics")
-redis-addr string
Redis Server Host&Port (default "localhost:6380")
-type int
which finder to use Polygon(0) or Fuzzy(1)
For example, start DefaultFinder server:
tzf-server
Or start FuzzyFinder based server:
tzf-server -type 1
Note
Please note that the live demo below is runned on a free plan of Render, so it may take a while to start the server. Please do not use it for production.
I have little knowledge about frontend development so it's just a experiment, most codes are written by ChatGPT 3.5. You can access the prompts from gist.
Note
Please note that the live demo below is runned on a free plan of Render, so it may take a while to start the server. Please do not use it for production.
A swagger UI can be found at
http://localhost:8080/swagger/index.html
.
Or live demo: https://tzf-server.ringsaturn.me/swagger/index.html
curl "http://localhost:8080/api/v1/tz?longitude=116.3883&latitude=39.9289"
or live demo:
curl "https://tzf-server.ringsaturn.me/api/v1/tz?longitude=116.3883&latitude=39.9289"
Output:
{
"timezone": "Asia/Shanghai",
"abbreviation": "CST",
"offset": "28800s"
}
curl "http://localhost:8080/api/v1/tzs?longitude=87.6168&latitude=43.8254"
or live demo:
curl "https://tzf-server.ringsaturn.me/api/v1/tzs?longitude=87.6168&latitude=43.8254"
Output:
{
"timezones": [
{
"timezone": "Asia/Shanghai",
"abbreviation": "CST",
"offset": "28800s"
},
{
"timezone": "Asia/Urumqi",
"abbreviation": "+06",
"offset": "21600s"
}
]
}
curl "http://localhost:8080/api/v1/tzs/all"
or live demo:
curl "https://tzf-server.ringsaturn.me/api/v1/tzs/all"
Output:
{
"timezones": [
{
"timezone": "Africa/Abidjan",
"abbreviation": "GMT",
"offset": "0s"
},
// ...
{
"timezone": "Etc/GMT+12",
"abbreviation": "-12",
"offset": "-43200s"
}
]
}
$ redis-cli -p 6380
127.0.0.1:6380> GET_TZ 116.3883 39.9289
Asia/Shanghai
127.0.0.1:6380> GET_TZS 87.4160 44.0400
1) "Asia/Shanghai"
2) "Asia/Urumqi"
>>> from redis import Redis
>>> rc = Redis.from_url("redis://localhost:6380")
>>> rc.ping()
True
>>> rc.execute_command("get_tz", 116.3883, 39.9289).decode()
'Asia/Shanghai'
>>> rc.execute_command("get_tzs", 87.4160, 44.0400)
[b'Asia/Shanghai', b'Asia/Urumqi']