Skip to content

Commit

Permalink
Fix Typos and Update File Save Location
Browse files Browse the repository at this point in the history
  • Loading branch information
jblanked committed Nov 10, 2024
1 parent ff51e9b commit 2b2cecd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
37 changes: 31 additions & 6 deletions callback/web_crawler_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,28 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context)
{
if (!sent_http_request)
{
snprintf(
fhttp.file_path,
sizeof(fhttp.file_path),
STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler/received_data.txt");

fhttp.save_received_data = true;
if (app_instance->file_type && app_instance->file_rename)
{
snprintf(
fhttp.file_path,
sizeof(fhttp.file_path),
STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler/%s%s",
app_instance->file_rename,
app_instance->file_type);
}
else
{
snprintf(
fhttp.file_path,
sizeof(fhttp.file_path),
STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler/received_data.txt");
}

if (strstr(app_instance->http_method, "GET") != NULL)
{
canvas_draw_str(canvas, 0, 10, "Sending GET request...");

fhttp.save_received_data = true;
fhttp.is_bytes_request = false;

// Perform GET request and handle the response
Expand All @@ -85,6 +96,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context)
{
canvas_draw_str(canvas, 0, 10, "Sending POST request...");

fhttp.save_received_data = true;
fhttp.is_bytes_request = false;

// Perform POST request and handle the response
Expand All @@ -94,6 +106,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context)
{
canvas_draw_str(canvas, 0, 10, "Sending PUT request...");

fhttp.save_received_data = true;
fhttp.is_bytes_request = false;

// Perform PUT request and handle the response
Expand All @@ -103,6 +116,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context)
{
canvas_draw_str(canvas, 0, 10, "Sending DELETE request...");

fhttp.save_received_data = true;
fhttp.is_bytes_request = false;

// Perform DELETE request and handle the response
Expand All @@ -113,6 +127,7 @@ void web_crawler_view_draw_callback(Canvas *canvas, void *context)
// download file
canvas_draw_str(canvas, 0, 10, "Downloading file...");

fhttp.save_received_data = false;
fhttp.is_bytes_request = true;

// Perform GET request and handle the response
Expand Down Expand Up @@ -1046,6 +1061,16 @@ void web_crawler_setting_item_file_read_clicked(void *context, uint32_t index)
}
UNUSED(index);
widget_reset(app->widget_file_read);

if (app->file_rename && app->file_type)
{
snprintf(fhttp.file_path, sizeof(fhttp.file_path), "%s%s%s", RECEIVED_DATA_PATH, app->file_rename, app->file_type);
}
else
{
snprintf(fhttp.file_path, sizeof(fhttp.file_path), "%s%s%s", RECEIVED_DATA_PATH, "received_data", ".txt");
}

// load the received data from the saved file
FuriString *received_data = flipper_http_load_from_file(fhttp.file_path);
if (received_data == NULL)
Expand Down
2 changes: 1 addition & 1 deletion flip_storage/web_crawler_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void save_settings(
{
// Create the directory for saving settings
char directory_path[256];
snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler_app");
snprintf(directory_path, sizeof(directory_path), STORAGE_EXT_PATH_PREFIX "/apps_data/web_crawler");

// Create the directory
Storage *storage = furi_record_open(RECORD_STORAGE);
Expand Down
2 changes: 1 addition & 1 deletion flipper_http/flipper_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// STORAGE_EXT_PATH_PREFIX is defined in the Furi SDK as /ext

#define HTTP_TAG "WebCrawler" // change this to your app name
#define HTTP_TAG "Web Crawler" // change this to your app name
#define http_tag "web_crawler" // change this to your app id
#define UART_CH (FuriHalSerialIdUsart) // UART channel
#define TIMEOUT_DURATION_TICKS (5 * 1000) // 5 seconds
Expand Down
2 changes: 1 addition & 1 deletion web_crawler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "web_crawler_icons.h"
#include <storage/storage.h>

#define TAG "WebCrawler"
#define TAG "Web Crawler"
extern char *http_method_names[];

// Define the submenu items for our WebCrawler application
Expand Down

0 comments on commit 2b2cecd

Please sign in to comment.