r/ryelang • • Oct 22 '26

Example: Simple HTTP service that analyzes IP-s

Post image

I was working with maxmind's GeoIP database in the last post. I made a simple script that analyzed a bunch of logs and returned me the countries grouped and ordered by count. You can see it here.

Now I turned that code into a HTTP service, added ASN database, and also added comparisson to ASN to the asn-bad-list ( for example: https://github.com/brianhama/bad-asn-list )

BTW: What is ASN? Autonomous System Number (ASN) is a unique, globally recognized identifier assigned to an Autonomous System (AS)—which is a large network or a group of IP networks managed by a single administrative entity

All this is served over simple HTTP server. A small test using curl:

useLinux >> curl http://localhost:9061/check-ip?ip=188.198.123.123
 country|si  org|telekom_slovenije_d.d.  asn|5603  bad-asn|0  address|narocnik.mobitel.si 
useLinux >> curl http://localhost:9061/check-ip?ip=185.209.196.133
 country|de  org|31173_services_ab  asn|39351  bad-name|esab_as_se  bad-asn|1  address|no_host 
use Linux >> curl http://localhost:9061/check-ip?ip=8.8.8.8
 country|us  org|google_llc  asn|15169  bad-name|google_google_inc._us  bad-asn|1  address|google 

Script is pretty self explanatory I think, but uses a lot of Rye specifics also ... so there are some not complex, but probably unknown mechanisms to you user. You can learn about them, if you look at Meet Rye. Or ask away on our discord or comments.

(Look at the comparison with Python script that does the same in the comment)

5 Upvotes

1 comment sorted by

1

u/middayc Oct 22 '26 edited Oct 22 '26

It is apples and oranges in certain regard, or cereal and snakes (and flasks), but it's a lot of snakes and less of cereal anyway :) . I asked gemini chat to produce Python script with the same functionality which you see on the right. It used Flask for http server. ChatGPT's user Python's http.server and was even longer.