upload log files to lighttpd, read using javascript html page - javascript

i'm using my beaglebone as my host device that's running lighttpd. my beaglebone is running another program that creates .log files.
I want to be able to connect my beaglebone to a laptop, open up the webpage that lighttpd's running and choose the .log file to review and be able to review it.
I assume this means I would have to
1) upload .log files to lighttpd server
2) html/js script to choose from these log files and view
I currently have a javascript/html file that lets me choose a file and displays it - but only on the local server (so from my laptop instead of the specific beaglebone logs folder)
If this is the right way to go about it, can anyone help me get started with some links/info? I've never worked with lighttpd/javascript before.
if not, point me in the right direction.
the current tutorial i'm looking at is http://www.alecjacobson.com/weblog/?p=1645&cpage=1#comment-311815 to create the javascript/html file

You can have a folder in on the beaglebone which contains logs and you can list the contents of the directive with mod_dirlisting.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModDirlisting
You can use mod_alias to map the folder into your web server docroot.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAlias
You should probably restrict access to view the logs using mod_auth.
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAuth

Related

HTML - Choose local path to move a file

I'm going to create a web app that's going to run locally on the user's computer.
First off, the user has downloaded a JSON file that ended up on "my download files" locally on their computer.
So they are going to browse to e.g myportal.local and there they are going to select the downloaded JSON file and also they need to choose a local location (directory).
To simply the workflow
Go to myportal.local in the browser
Choose in the form the JSON file
Choose a local path on the machine
Press submit and other scripts will parse and download things to the chosen folder.
Steps 1,2 and 4 is not a problem, it’s step 3 on how to choose a local destination.
It isn't possible to do this directly in the browser.
Since the HTTP server is running on the same computer, you could use server side code to examine the structure of the computer's file system and generate a user interface in HTML for the user to pick directories with.

Build URL to data file download with link to folder

I have a web application that triggers actions at the server side which result in the generation of data files.
The so generated data files are stored within a folder at drive different from the one where the Web application is.
What I tried so far is to create a shortcut (Windows Server) next to the Index.html, where the shortcut points to the folder at the second drive.
This solution does not appear to work:
If I copy the data file to the same folder where the Index.html file is and enter navigate to the URL httm://127.0.0.1:324324/Data_File.xlsx I get the file downloaded.
If I enter httm://127.0.0.1:324324/MyShortcut/Data_File.xlsx (where MyShortcut points to a folder in drive D) the attempt fails.
How can I achieve this?
The need to access files in the different drive is essential.
You need to configure your server to serve that folder under different location. The only reason you are able to see your app and access that folder is cause server is set up to serve it ATM, not because you are making the right calls from the front or cause the front is asking nicely.
Don't know what Windows server version you are using and IIS version that goes on it, or are you even using IIS (you most probably do) but depending on what you use you need to do something in a lines of this:
IIS7 config
What you probably wanna do is create virtual folder in IIS. Try looking into it, then if you fail ask a question with proper tags according where are you stuck.
I don't see how this is connected to front-end at all so front end tags wont get you far.
EDIT:
Oh, in that case get a second file server running for that folder? This should be the fastest way, use what you can from this list: list

Reading a file from a folder when it gets created using nodejs

Following operations are going to take place :
A text file is created using a java program and it gets stored in a folder
The file needs to be read and displayed in the text box which is present in the browser UI.
For this to happen, the java script needs to check the folder till the text file becomes available and then read it and display it in the text box.
How will the javascript come to know when the text file is available in the folder and how is it going to read it and display it.
We are using Nodejs as the container and Ember Java for the web framework
This is only possible if you run Ember locally rather than served from a web server.
Create an in-repo addon in your Ember app. It will have Node context.
Have the addon watch the folder for changes. Read the file when it's available
Have the addon run a web server that responds with file contents when it's available.
Configure your app for long polling the web server.
If you do need to server the app from a web server, then you're out of luck. You can try running a desktop app on the computer that watches the folder for changes then sends the file contents to the server. Then the app can request the file from the server. That's more elaborate.

How to access local image when setting the background image in javascript

My goal is to set the background image from a local image on my computer.
I have two lines of code, one that works and one that doesn't:
(the local one does not work)
_html.style.backgroundImage = 'url("urlsourceblahblahblah")';
_html.style.backgroundImage = 'url("/~/Content/images/Image1.jpg")';
When I try running the second one (the local one), this is the error that I get:
GET http://localhost:23433/~/Content/images/Image1.jpg 404 (Not Found)
I can verify that the image path is correct, even if I put the image file in the same directory to make things simple. I know from documentation that the backgroundImage property in JS requires url(). Is there any reason why this wouldn't work?
This is a tricky one... I can think of some problems this can have:
The server doesn't know what ~ refers to (are you running windows?)
The user running the server is not the same as the one you are logged in as. (~ stands for home directory, and when server evaluates it'll lead to user running the server home directory).
The server is configured to ignore every request which is above it's www / html / localweb folder. (Altough in this case it would be weird to reply with a 404, a 403 would make more sense)
By the way, this is only possible if the server and the client are on the same machine. I don't know why you want it, but if you pretend to upload a website and have its background set to some field on the client machine, then simply forget about it.
The ~ abbreviation for your home directory is not recognized by the browser. However, expanding it will only help if the image is in a directory that is being served on local host. I don't know what you are using for a web server, but you'll need to find out what directory it is expecting to serve as its root
You can't refer to an image from the users machine. The browser does not have access to the users file system, otherwise, any website you visit would be able to access your "Pictures" folder for example.
The image you use needs to be in your website directory or another public url. If you need to use a picture from the users machine, then you should do so with a file uploader.

how to execute a batch file from a website

I know this sounds fishy, but I'm trying to run a batch file from a website. Our users are seniors that wouldn't know how to do anything with a computer. Our software is a replacement for the windows shell. When the computer starts, it automatically starts our software and nothing else. Our users never see windows, only our application. It is written in C# and after presenting a login screen shows the user a full-screen web application.
We have a system where we update our application via a batch file it downloads by itself. However, the dialog window asking the user for an update is broken (minimized, so the user doesn't see it). Now our users can't update our application. We fixed this bug in the current version, but users can't get the new version.
Is there any way to run a batch file from a website? The batch file is already downloaded by our application, it just needs to run. It is located in c:/users/the_user/appdata/roaming/. If anyone has any idea how we could run the batch file remotely, that would be awesome.
I know it would be a huge security risk if something like this is possible, please don't point that out to me. It is also not their computer that runs the software, but one we provide for the purpose of the application. If a user does not want to use the app anymore, we take the computer back as well. There can not be any personal data saved on it, because there is simply no way for the user to get it on there.
Our update process goes like this: the C# app downloads a zip from our web-server if there is a new version -> the app asks the user if he/she wants to install that update -> if the user presses yes, the c# app closes and runs the batch file that copies the contents from the zip to the folder where our c# app resides -> at the end of the batch file is a system restart command, after restarting the tablet our app starts up and the user can continue using it.
No, it can't launch a batch file from a website.
A browser will just save it to the local drive or open it in the web page.

Categories