Skip to content

Instantly share code, notes, and snippets.

@takurx
Last active April 6, 2025 22:46
Show Gist options
  • Save takurx/c1d415a4551d25c7faa706cdec28b14b to your computer and use it in GitHub Desktop.
Save takurx/c1d415a4551d25c7faa706cdec28b14b to your computer and use it in GitHub Desktop.
test, my local API + MLIT Data platfrom + Kong Gateway

log_test_kong_gateway-0

(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ python run_kyun_system.py
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ sudo curl -Ls https://get.konghq.com/quickstart | sudo bash
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -s -X POST http://localhost:8001/services \
>    --data name=dpf_service \
>    --data url='https://www.mlit-data.jp/api/v1'
HTTP/1.1 201 Created
Date: Mon, 24 Mar 2025 21:21:42 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 1acc2e0392c511397539406a97baba05
Content-Length: 384
X-Kong-Admin-Latency: 15
Server: kong/3.9.0.0-enterprise-edition

{"client_certificate":null,"write_timeout":60000,"protocol":"https","id":"3a2364f0-7db9-41ce-98dd-320e15567097","tls_verify":null,"tls_verify_depth":null,"tags":null,"connect_timeout":60000,"created_at":1742851302,"retries":5,"read_timeout":60000,"ca_certificates":null,"host":"www.mlit-data.jp","updated_at":1742851302,"name":"dpf_service","port":443,"path":"/api/v1","enabled":true}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -X POST http://localhost:8001/services/dpf_service/routes \
>     --data 'paths[]=/dpf_mock' \
>     --data name=dpf_route
HTTP/1.1 201 Created
Date: Mon, 24 Mar 2025 21:22:00 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 2016a74a18d1eb71e7fb380e866a4314
Content-Length: 485
X-Kong-Admin-Latency: 20
Server: kong/3.9.0.0-enterprise-edition

{"destinations":null,"methods":null,"protocols":["http","https"],"https_redirect_status_code":426,"id":"fcb29240-57a0-484d-a14a-82ea9ded3f96","response_buffering":true,"updated_at":1742851320,"paths":["/dpf_mock"],"name":"dpf_route","snis":null,"tags":null,"preserve_host":false,"created_at":1742851320,"service":{"id":"3a2364f0-7db9-41ce-98dd-320e15567097"},"strip_path":true,"headers":null,"regex_priority":0,"sources":null,"hosts":null,"request_buffering":true,"path_handling":"v0"}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ 
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -X GET http://localhost:8001/services/dpf_service/routes/dpf_route
{"destinations":null,"methods":null,"protocols":["http","https"],"https_redirect_status_code":426,"id":"fcb29240-57a0-484d-a14a-82ea9ded3f96","response_buffering":true,"updated_at":1742851320,"paths":["/dpf_mock"],"name":"dpf_route","snis":null,"tags":null,"preserve_host":false,"created_at":1742851320,"service":{"id":"3a2364f0-7db9-41ce-98dd-320e15567097"},"strip_path":true,"headers":null,"regex_priority":0,"sources":null,"hosts":null,"request_buffering":true,"path_handling":"v0"}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -s -X POST http://localhost:8001/services \
>    --data name=kyon_service \
>    --data url='http://localhost:5000/'
HTTP/1.1 201 Created
Date: Mon, 24 Mar 2025 21:23:34 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 4416ff6153f246255d338f55aee9a339
Content-Length: 372
X-Kong-Admin-Latency: 17
Server: kong/3.9.0.0-enterprise-edition

{"client_certificate":null,"write_timeout":60000,"protocol":"http","id":"fbda34a8-2dcd-4671-ad15-aa1d40360d41","tls_verify":null,"tls_verify_depth":null,"tags":null,"connect_timeout":60000,"created_at":1742851414,"retries":5,"read_timeout":60000,"ca_certificates":null,"host":"localhost","updated_at":1742851414,"name":"kyon_service","port":5000,"path":"/","enabled":true}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ 
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -X POST http://localhost:8001/services/kyon_service/routes \
>     --data 'paths[]=/kyon_mock' \
>     --data name=kyon_route
HTTP/1.1 201 Created
Date: Mon, 24 Mar 2025 21:23:47 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 67f456133c35591da031db5327e32661
Content-Length: 487
X-Kong-Admin-Latency: 20
Server: kong/3.9.0.0-enterprise-edition

{"destinations":null,"methods":null,"protocols":["http","https"],"https_redirect_status_code":426,"id":"afecb6a6-a54e-4fc8-9952-d70d93692fe6","response_buffering":true,"updated_at":1742851427,"paths":["/kyon_mock"],"name":"kyon_route","snis":null,"tags":null,"preserve_host":false,"created_at":1742851427,"service":{"id":"fbda34a8-2dcd-4671-ad15-aa1d40360d41"},"strip_path":true,"headers":null,"regex_priority":0,"sources":null,"hosts":null,"request_buffering":true,"path_handling":"v0"}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ 
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -X GET http://localhost:8001/services/kyon_service/routes/kyon_route
{"destinations":null,"methods":null,"protocols":["http","https"],"https_redirect_status_code":426,"id":"afecb6a6-a54e-4fc8-9952-d70d93692fe6","response_buffering":true,"updated_at":1742851427,"paths":["/kyon_mock"],"name":"kyon_route","snis":null,"tags":null,"preserve_host":false,"created_at":1742851427,"service":{"id":"fbda34a8-2dcd-4671-ad15-aa1d40360d41"},"strip_path":true,"headers":null,"regex_priority":0,"sources":null,"hosts":null,"request_buffering":true,"path_handling":"v0"}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ 

log_test_kong_gateway-1

curl -X POST -H "Content-Type: application/json" \
    -H "apikey: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
    -d "{\"query\": \"{ search(term:\\\"つくば\\\", attributeFilter:[{attributeName:\\\"全国道路施設点検データベース\\\"}], first:5) { totalNumber } }\" }" \
    -i http://localhost:8001/services/dpf_service/
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ chmod 755 ./test_api_shell-2.
sh
(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ ./test_api_shell-2.sh
HTTP/1.1 405 Not Allowed
Date: Mon, 24 Mar 2025 22:37:51 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: b4fb7e3782ca04611e7b843ccec7ad3a
Content-Length: 32
X-Kong-Admin-Latency: 5
Server: kong/3.9.0.0-enterprise-edition

{"message":"Method not allowed"}

log_test_kong_gateway-2

cd ~/LoRaWorks_230822/test_mlit-dpf-api
python run_kyun_system.py
sudo curl -Ls https://get.konghq.com/quickstart | sudo bash
curl -i -s -X POST http://localhost:8001/services \
   --data name=dpf_service \
   --data url='https://www.mlit-data.jp/api/v1'
curl -i -X POST http://localhost:8001/services/dpf_service/routes \
    --data 'paths[]=/dpf_mock' \
    --data name=dpf_route

WIP

curl -i -s -X POST http://localhost:8001/services \
   --data name=kyon_service \
   --data url='http://localhost:5000/api/kyun/sightings'
   --data url='http://localhost:5000/'
curl -i -X POST http://localhost:8001/services/kyon_service/routes \
    --data 'paths[]=/kyon_mock' \
    --data name=kyon_route
streamlit run folium_kyun_visualization.py

log_test_kong_gateway-3.md

1

cd
cd LoRaWorks_230822/test_mlit-dpf-api
python run_kyun_system.py

2

sudo curl -Ls https://get.konghq.com/quickstart | sudo bash

3

curl -i -s -X POST http://localhost:8001/services \
    --data name=dpf_service \
    --data url='https://www.mlit-data.jp/api/v1'

curl -i -X POST http://localhost:8001/services/dpf_service/routes \
     --data 'paths[]=/dpf_mock' \
     --data name=dpf_route

4

curl -i -s -X POST http://localhost:8001/services \
    --data name=kyon_service \
    --data url='http://10.98.20.62:5000/'

curl -i -X POST http://localhost:8001/services/kyon_service/routes \
     --data 'paths[]=/kyon_mock' \
     --data name=kyon_route

5

streamlit run folium_kyun_visualization.py

log1

(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ python run_kyun_system.py
✅ All required dependencies are installed.

......
......

========================================
API test completed!

🗺️ Generating map visualization...
🦌 Kyun Sightings Map Generator 🦌
========================================
Using API at: http://localhost:5000
Map saved to kyun_map_20250407_064610.html

Would you like to open the map in your browser? (y/n)
y
Opening map in browser: /home/chino/LoRaWorks_230822/test_mlit-dpf-api/kyun_map_20250407_064610.html

You can manually open the map file in your web browser.
========================================

==================================================
  システムが正常に動作しています (System is running normally)
==================================================

API Server is running at: http://localhost:5000

Available endpoints:
  - http://localhost:5000/api/kyun/sightings
  - http://localhost:5000/api/kyun/coordinates
  - http://localhost:5000/api/kyun/sightings/<location_name>

Press Ctrl+C to stop the system when finished.

log2

(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ sudo curl -Ls https://get.konghq.com/quickstart | sudo bash
[sudo] password for chino: 

• Deploying Kong Gateway to Docker...
ℹ Debugging info logged to:
    /tmp/kong/quickstart/kong-quickstart.log
⏲︎ Downloading Docker images... ✔ 
⏲︎ Destroying previous kong-quickstart containers... ✔ 
⏲︎ Starting database... ✔ 
⏲︎ Starting Kong Gateway... ✔ 
⏲︎ Validating kong state... ✔ 

🐵 Kong Gateway Ready 🐵

=======================================================
 ⚒️                                   Using Kong Gateway
=======================================================

• Kong Gateway Data Plane endpoints:
    HTTP  = http://localhost:8000
    HTTPS = https://localhost:8443

• This script has written an environment file you can
  source to make connecting to Kong Gateway easier. 
  Run this command to source these variables into your
  environment:

→ source /tmp/kong/quickstart/kong.env

• Now you can make requests to your Kong Gateway using 
  variables from the file, for example:

→ curl -s $KONG_PROXY/mock

=======================================================
 ⚒️                              Administer Kong Gateway
=======================================================

• Kong Gateway Admin API endpoint:
   HTTP = http://localhost:8001

• To administer the gateway with curl:

→ curl -s https://localhost:8001

• To stop the gateway run:

→ curl -s https://get.konghq.com/quickstart | \ 
    bash -s -- -d -a kong-quickstart

Or remove the Docker container directly.

log3

(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -s -X POST http://localhost:8001/services \
>    --data name=dpf_service \
>    --data url='https://www.mlit-data.jp/api/v1'
HTTP/1.1 201 Created
Date: Sun, 06 Apr 2025 21:48:12 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 48fdac3cd21a2a0a838a0f739e638962
Content-Length: 384
X-Kong-Admin-Latency: 112
Server: kong/3.10.0.0-enterprise-edition

{"client_certificate":null,"tags":null,"connect_timeout":60000,"name":"dpf_service","read_timeout":60000,"protocol":"https","retries":5,"enabled":true,"created_at":1743976092,"updated_at":1743976092,"port":443,"id":"ea2ee326-062b-48fa-b4a2-238e0e45579a","host":"www.mlit-data.jp","tls_verify":null,"path":"/api/v1","write_timeout":60000,"tls_verify_depth":null,"ca_certificates":null}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -X POST http://localhost:8001/services/dpf_service/routes \
>     --data 'paths[]=/dpf_mock' \
>     --data name=dpf_route
HTTP/1.1 201 Created
Date: Sun, 06 Apr 2025 21:48:12 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 13a9c125167a83064710a10d159d5e52
Content-Length: 485
X-Kong-Admin-Latency: 13
Server: kong/3.10.0.0-enterprise-edition

{"https_redirect_status_code":426,"destinations":null,"tags":null,"headers":null,"name":"dpf_route","updated_at":1743976092,"strip_path":true,"protocols":["http","https"],"service":{"id":"ea2ee326-062b-48fa-b4a2-238e0e45579a"},"path_handling":"v0","response_buffering":true,"created_at":1743976092,"paths":["/dpf_mock"],"methods":null,"id":"b9b46152-af03-49ae-bcd7-e03510cb49ea","hosts":null,"regex_priority":0,"preserve_host":false,"sources":null,"snis":null,"request_buffering":true}

log4

(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -s -X POST http://localhost:8001/services \
>    --data name=kyon_service \
>    --data url='http://10.98.20.62:5000/'
HTTP/1.1 201 Created
Date: Sun, 06 Apr 2025 22:07:09 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 963a8952a8fab47cf3f6d11ed81e176b
Content-Length: 374
X-Kong-Admin-Latency: 16
Server: kong/3.10.0.0-enterprise-edition

{"client_certificate":null,"tags":null,"connect_timeout":60000,"name":"kyon_service","read_timeout":60000,"protocol":"http","retries":5,"enabled":true,"created_at":1743977229,"updated_at":1743977229,"port":5000,"id":"7a02a472-5054-4efd-b1fd-6e069b569a48","host":"10.98.20.62","tls_verify":null,"path":"/","write_timeout":60000,"tls_verify_depth":null,"ca_certificates":null}(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ curl -i -X POST http://localhost:8001/services/kyon_service/routes \
>     --data 'paths[]=/kyon_mock' \
>     --data name=kyon_route
HTTP/1.1 201 Created
Date: Sun, 06 Apr 2025 22:07:09 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 7f782c07c3832d1120318045ddae803a
Content-Length: 487
X-Kong-Admin-Latency: 16
Server: kong/3.10.0.0-enterprise-edition

{"https_redirect_status_code":426,"destinations":null,"tags":null,"headers":null,"name":"kyon_route","updated_at":1743977229,"strip_path":true,"protocols":["http","https"],"service":{"id":"7a02a472-5054-4efd-b1fd-6e069b569a48"},"path_handling":"v0","response_buffering":true,"created_at":1743977229,"paths":["/kyon_mock"],"methods":null,"id":"2a3bafd7-4f60-45f4-949a-9f900b4c0e1d","hosts":null,"regex_priority":0,"preserve_host":false,"sources":null,"snis":null,"request_buffering":true}

log5

(base) chino@chino-Legion-5-15IAH7H:~/LoRaWorks_230822/test_mlit-dpf-api$ streamlit run folium_kyun_visualization.py

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://10.98.20.62:8501
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment