HTTP Filer Server: Single file, cross platform, drag drop and start - http

I asked a previous question here but after reading the answers realised I hadn't done a very good job of defining my requirements.
Here's what I'm after:
Cross platform
Drag, drop and start
Preferably a single file
So to sum up I want something that I can just drag into a folder, start up and then it will start servering over http the contents of that folder.
Hope someone knows of something.
Cheers,
Chris

Python implementation:
#!/usr/bin/env python
import SimpleHTTPServer, BaseHTTPServer
def launchServer(ports):
for port in ports:
try:
serv = BaseHTTPServer.HTTPServer(('', port), SimpleHTTPServer.SimpleHTTPRequestHandler)
except:
continue
else:
print ("Launched on port " + str(port))
serv.serve_forever()
raise Exception("No ports available")
launchServer([80] + range(8000, 9000))
For a Windows executable, run this:
python setup.py py2exe
setup.py:
from distutils.core import setup
import py2exe
setup(console=['minipywebd.py'])
On Linux, chmod a+x the python file.

I have found a some-what small web server in the form of a Firefox addon. It works on any platform that Firefox works on. It can be installed very quickly and can be ready to use in around 45 seconds (I timed myself from the time I started downloading to the time I served my first page). The server sets up a directory for you to use right after it is installed so you could just drag it there and start viewing the page instantly. It also has limited server-side scripting capabilities(SJS) included but can be extended with common languages such as php and Perl. I don't think this would be the server you would use to host Google but it seems to be what you're looking for.
The download is here

Well it is quite late to answer this one: but python afaik is not single file ;-)
TCL is!
Look at www.equi4.com for a tclkit or starkit. TCL can implement an HTTP server easily. But with a TCL starkit you can even pack the content to be served into the very same file as the webserver and the TCL interpreter and possibly extension.
Building a complete solution is no rocket science but you will have to read yourself into the thing a bit. TCL can be learned in two to three hours if you ever programmed anything before.

Related

QT - qtwebsocket - can't connect

I'm using qtwebsocket from https://github.com/antlafarge/QtWebsocket on QT Creator 5.0, Linux 64bit. I'm trying connect to echo test:
wsSocket->connectToHost( "echo.websocket.org", 80 );
But I immediately get disconnected status. I tried also with ws:// and http:// prefix but same error. Any idea? I even don't know how to report a bug on this gitorious.
It is important to me to don't use webkit, I need pure TCP socket connection.
Regards
There is also a Qt websockets add-on module located at https://qt.gitorious.org/qt/qtwebsockets.
It has been tested on several platforms, and successfully succeeds with the AutoBahn Testsuite.
Just quickly looking at the example located:
https://github.com/antlafarge/QtWebsocket/tree/master/Example
I don't know the state of the project too well, but it looks like there is still a to-do list on what it can do; one item I noticed, it says WSS is not yet supported.
Try running both sides of the Client and Server in the included example, and see if you can get a connection in that context before trying the echo.websocket.org server.
Hope that helps.

iMacros-like program that can run from the command line to automate browser actions?

Here's what I would like to do:
Cron execute an iMacro (or iMacro-like) script on a headless unix server - essentially doing my browser interactions for me.
Is this possible?
I'm sure cURL won't be able to traverse the DOM and trigger user events. iMacros would be perfect if I could run it in unix CLI, which you can, but I run a headless server without Xorg and obviously FF requires Xorg. iMacro with Lynx would be good but I doubt iMacro works with Lynx.
Anyone got any ideas?
Old question, but I was looking for about the same thing, and I found this post on Google. Here the answser :
There is some headless browser which can run on an Unix system without Xorg. You can try CasperJS, PhantomJS or Zombie by example.

log4net with asp.net mvc - can't watch file for changes

So in a console .Net application I can watch all my log4net events stream by with (the powershell command) get-content .\log.log -Wait which is similar to the linux tail command and I assume uses FileSystemWatcher under the hood.
For some reason, whenever I have an asp.net Mvc application this will not work. To be clear, the log file IS written to. I can get-content .\log.log as many times as I want and get the most recent results, but with the -wait parameter I never see the changes scroll past.
Does anyone have any insight into what might be going on here?
UPDATE: found a working solution for my case, not sure whether this would help you out.
Instead of using PowerShell, I downloaded win-bash and now I'm using this familiar Unix command which works perfectly for me.
tail -f access.log
I'm not that familiar with .Net programming. Could it be a working solution in your case to use win-bash project's bash.exe instead of PowerShell?
I am experiencing similar issue when trying to "tail" Apache access log in PowerShell.
Get-Content .\access.log -Wait
I noticed that when my Apache HTTP server is running, it has a handle open to acccess.log and -Wait doesn't work. Stopping HTTP server releases the handle and when I made manual changes to access.log using text editor my PowerShell window immediately reflected changes in the console.
So I assume if some other program has a handle open to the file, changes are not reflected to console. Unfortunately I haven't found a way around this issue so far.

How do I get wkhtmltopdf running for a Drupal site on cPanel shared hosting?

First off, I will acknowledge that I am aware of another similar thread on the topic of wkhtmltopdf, but it was not similar enough to resolve my issue. Here's the other thread: wkhtmltopdf
Second, I will say that I have successfully used wkhtmltopdf with a Drupal site on a dedicated server that I run, where I installed the libX11 and used the most recent static version of wkhtmltopdf. That's on a CentOS 5 system and it runs nicely.
So, I have another hosting arrangement and I need to get the wkhtmltopdf to work, because it does the most amazing job producing bookmarked PDFs. The PDFs are beautiful.
The hosting is cPanel. I determined that it is on a server that has CentOS 5.5. It is not a problem to drop the static wkhtmltopdf in the print module's lib folder. However, I get the following message back in the Drupal admin status reports page (admin/reports/status).
It says,
"wkhtmltopdf library
The currently selected version of wkhtmltopdf () is not supported. Please update to a newer version."
I have obtained all of the needed .so files for CentOS 5, based on what jockie provided in his answer in the other StackOverflow thread.
Can someone knowledgeable confirm that his list was complete?
The idea of a shell script wrapper seems interesting and appears could be done for Drupal, if the naming of the shell script is called something like "wkhtmltopdf-wrapper.sh".
I have tried to use the shell script code that jockie provided, in a shell script. I did place all of the .so files in a sub-folder called "lib". I confess that I do not know what such things mean, in the script:
export HOME="$PWD"
Can someone interpret for me, what $PWD means?
export LD_LIBRARY_PATH="$PWD/lib/"
I understand that the script is going to get the .so files with that line, yes?
And can someone interpret the following line:
exec $# 2>/dev/null
What I am wondering is, where does the actual pdf get output? I did run the script. It did not throw any errors. However, I did not see a resulting PDF file.
Also, jockie's directions are not totally clear or defined enough. He says, "(some of them are symlinks)" under the list of .so files. Are such lines (in his list), the symlinks?:
lib/libX11.so.6 lib/libX11.so.6.2.0
Or am I mistaken? I was able to get all of them, so I don't know why they would be symlinks. The only thing is, that some of the versions are different. Do I need to delete the following files and make symlinks instead?:
lib/libX11.so.6
lib/libXau.so.6
lib/libxcb.so.1
lib/libXext.so.6
Should the shell script code be written differently, with Drupal in mind?
Thanks for reading and I hope someone can help!
...Finally, if anyone knows of a better solution, please share! Again, I appreciate the help!
...There does not seem to be a way, here on StackOverflow.com to notify jockie to check out this thread. I wish there was a way to write to them or notify them, so that they could clarify for them-self or contribute to this thread as well. If someone knows of a way, please let me know that too!

Run Qt application on startup as Linux daemon

I've developed a Qt application which contains a TCP server and such. I'm now trying to make Ubuntu packages and let the application automatically start on startup.
The application needs to be running even if nobody is logged in, which means a daemon started via a script in /etc/init.d/
I tried simply running the application on start and sending a kill-signal on stop in the init.d script but that means the application runs in the foreground and blocks the init-script.
Forking like in an other question almost seems to work, I get 'unknown error' after trying to start a TCP server. Nevertheless, there should be an easy to way to write a init-script that runs my application in the background on startup on the various Linux distributions.
Could anyone point me in the right direction?
Using Ubuntu 9.10 with Qt 4.5
The best way is probably to use QtService where the work of forking is taken care of for you.
However, if you want to continue to build your own, you should either background the application or run it via start-stop-daemon that comes with OpenRC or a similar utility for your distribution.
Also, make sure that you only link to the QtCore shared library. Although the application might be command line and never pull up the GUI, that doesn't mean that X isn't required in order for the application to run. For example, a set of unit tests:
$ ldd runTests | grep Qt
libQtTest.so.4 => /usr/lib/qt4/libQtTest.so.4 (0x00007fd424de9000)
libQtXml.so.4 => /usr/lib/qt4/libQtXml.so.4 (0x00007fd424baa000)
libQtGui.so.4 => /usr/lib/qt4/libQtGui.so.4 (0x00007fd4240db000)
libQtCore.so.4 => /usr/lib/qt4/libQtCore.so.4 (0x00007fd422644000)
Because QtGui is present, all the X libraries are also brought in, although filtered from the above output.
Is your program a GUI application or does it work without GUI?
Why don't you just background it within the init script using &?
You need to add a symbolic link into any of the rc?.d directories under /etc depending on the default runlevel. Or use the update-rc.d script: first you need to create a script into /etc/init.d that executes the application; second, use the update-rc.d script to add the needed files to start.
You can find information about how to do it by reading update-rc.d manual page:
$man update-rc.d
I think the simplest way is to not have any daemonize logic in your application itself, instead use a helper program to start the app in the background and manage a pid for it.
For example, startproc.
You can take a look at the many scripts already in your /etc/init.d for inspiration. From what I see there, most of standard linux daemons depend on startproc for start, and killproc for stopping.

Resources