Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Simple CLI tool to detect if a website is up or down
- // Uses the DownFor API to get status of website
- // Written by SmallDoink#0666 | ScaredKYS
- import 'package:http/http.dart' as http;
- import 'dart:io';
- import 'dart:convert';
- main(List<String> args) async {
- // Read system arguments
- var arg = args[0];
- var url = 'https://api.downfor.cloud/httpcheck/'+arg; // Define URL for the http package
- var response = await http.get(url); // Wait for the response to finish before defining
- var body = jsonDecode(response.body); // Decode the JSON response
- if (body['isDown'] == false) { // Handle the JSON response
- print('The website is up!');
- } else print('The website is down! (Status Code: ${body['statusCode']})') ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement