@@ -13,24 +13,30 @@ use std::env;
1313
1414#[ tokio:: main]
1515async fn main ( ) {
16- let arg = if env:: args ( ) . count ( ) == 2 {
16+ // Get API URL from environment or use default
17+ let api_url = env:: var ( "PASTE_API_URL" )
18+ . unwrap_or_else ( |_| "https://api-umbra.batbin.me" . to_string ( ) ) ;
19+
20+ // Get assets path from command line or use default
21+ let assets_path = if env:: args ( ) . count ( ) >= 2 {
1722 env:: args ( ) . nth ( 1 ) . unwrap ( )
1823 } else {
19- panic ! ( "Absolute path of pastes directory *without* trailing slash was not passed!" )
24+ "/data" . to_string ( )
2025 } ;
2126
2227 let mut png_header = HeaderMap :: new ( ) ;
2328 png_header. insert ( "Content-type" , HeaderValue :: from_static ( "image/png" ) ) ;
2429
25- let image = image:: open ( format ! ( "{}/{}" , arg , "editor.png" ) )
30+ let image = image:: open ( format ! ( "{}/{}" , & assets_path , "editor.png" ) )
2631 . expect ( "ERR No template image found at provided path" )
2732 . to_rgba8 ( ) ;
2833
2934 let font: Font < ' static > = Font :: try_from_bytes ( include_bytes ! ( "FiraCode-Retina.ttf" ) as & [ u8 ] ) . unwrap ( ) ;
3035
31- utils:: init_state ( arg , image, font) ;
36+ utils:: init_state ( api_url . clone ( ) , assets_path , image, font) ;
3237
3338 println ! ( "Starting warp server on port 3030" ) ;
39+ println ! ( "Using paste API: {}" , api_url) ;
3440
3541 let p = warp:: path ( "p" ) ;
3642 let ap = utils:: with_state ( )
@@ -44,6 +50,6 @@ async fn main() {
4450 . and_then ( handlers:: root_handler_known) ;
4551
4652 warp:: serve ( p. and ( ap) . or ( pk. and ( apk) ) . with ( warp:: reply:: with:: headers ( png_header) ) )
47- . run ( ( [ 127 , 0 , 0 , 1 ] , 3030 ) )
53+ . run ( ( [ 0 , 0 , 0 , 0 ] , 3030 ) )
4854 . await ;
4955}
0 commit comments