File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 2121
2222 - name : Build TypeScript
2323 run : tsc -p "./www/tsconfig.json"
24+ - name : Prepare GET server
25+ run : curl "https://ifconfig.me/ip" -o "ip.txt"
2426 - name : Run custom build script
2527 run : python3 "www/build.py" "${{ secrets.SECRET_STRING }}"
2628
3234 - name : Deploy to GitHub Pages
3335 id : deployment
3436 uses : actions/deploy-pages@v4
37+
38+ - name : Run GET server
39+ run : python3 "www/server.py" "${{ secrets.SECRET_STRING }}" 60
Original file line number Diff line number Diff line change 1010 < body >
1111 < button > Hello, World!</ button >
1212 < script src ="ts/index.js "> </ script >
13+ < script >
14+ fetch ( "ip.txt" )
15+ . then ( ( response ) => {
16+ console . log ( response ) ;
17+ } )
18+ . error ( console . error ) ;
19+ </ script >
1320 </ body >
1421</ html >
Original file line number Diff line number Diff line change 1+ import http .server
2+ import socketserver
3+ import threading
4+ import time
5+ import argparse
6+
7+ GET = None
8+
9+
10+ class RequestHandler (http .server .BaseHTTPRequestHandler ):
11+ def do_GET (self ):
12+ self .send_response (200 )
13+ self .send_header ("Content-Type" , "text/plain" )
14+ self .end_headers ()
15+ self .wfile .write (str (GET ).encode ())
16+
17+
18+ parser = argparse .ArgumentParser (
19+ description = "Start a simple GET request server which returns a static string."
20+ )
21+ parser .add_argument ("GET" , type = str , help = "GET Request return value" )
22+ parser .add_argument (
23+ "shutdown_after" ,
24+ type = int ,
25+ nargs = "?" ,
26+ default = 600 ,
27+ help = "Shutdown after __ seconds (default 600 seconds, 10 minutes)" ,
28+ )
29+ args = parser .parse_args ()
30+ GET = args .GET
31+
32+ server = socketserver .TCPServer (("0.0.0.0" , 8080 ), RequestHandler )
33+ server_thread = threading .Thread (target = server .serve_forever )
34+ server_thread .start ()
35+ print (f"Shutdown in { args .shutdown_after } " )
36+ time .sleep (args .shutdown_after )
37+ print ("Closing server" )
38+ server .shutdown ()
39+ print ("Server closed" )
You can’t perform that action at this time.
0 commit comments