I Need to set-up a server which can host a Haskell generated website. If I use PHP I can host it on a Apache sever. Likewise if I create a Haskell thing what are the suitable webservers I can use? I have tried several but most of then ended with an error. Please give me some details to set-up a Haskell running webserver.
Main need is to create a dynamic website which based on Haskell programming language.
I'd take a look at Yesod or the Snap Framework
There's more discussion on the pros and cons of each on a recent Reddit question.
Generally haskell isn't served through an Apache module. You either set up a cgi or fcgi executable, and then use apache, nginix, etc. to call that, or you use a framework like snap or happstack that provides its own server. You then don't need apache, nginix, or whatever else unless you want to use it as a proxy (to provide https, for example).
For reference, see the web category at the Haskell wiki: http://www.haskell.org/haskellwiki/Web
Edit: for just running hsp, the hsp-cgi package works: http://hackage.haskell.org/package/hsp-cgi
And for a more robust way to run hsp (not involving launching the cgi executable on each request, allowing for more persistent state therefore, etc.) then happstack is your best bet, I think, since it has hsp integration built in.
You should be able to tell the Apache how to process haskell files in just the same way Apache passes php-files to the PHP interpreter. So, think of a file extension of your haskell files, then see the Apache documentation on filters/file-endings to tell it that such files should be passed through your favorite Haskell interpreter.
Related
A few years back, we had a programmer create a type of calculator for use in the audio industry. It was created/compiled in C - and is an .exe we offer for free download. once a user downloads it, they can run it locally.
Our goal is to move that application/calculator to the "cloud" where any user can hypothetically visit a URL, and the calculator is there, running, and ready for user interaction by multiple users.
Is what I describe possible?
Will I need Azure?
What exactly in Azure will I need (i.e. which products/resources)?
Do I need to use the compiled/decompiled version?
Will we need to change any code in the .exe to make this work?
What do I not know that I should know?
I sincerely appreciate any and all input from those that are probably reading this and fully understanding the simplicity of it while I struggle to wrap my head around it.
Thank you!
#Alex, Thank you so much for the response. I apologize I was late getting back to you - have 4 kiddos home - I am actually not sure how to answer that fully. Here is a link to the freely downloadable file we offer to anyone and everyone - it does require an email, but that is just for notifications when the version is updated. https://caf.prosoundtraining.com/verify/ and here is the home page of the site: https://caf.prosoundtraining.com - It works by the user downloading the program (which is what we would like to move to the cloud), and then inputing various values for determining what watt amplifier to use based on speaker selection, length of cables, distance of audience from speakers, etc. basically several calculation tools like that, and then the main program that allows users to visualize amplifier performance via running signal tests through the amplifier. Once a user downloads the program, the calculators (which are separate in the decompiled version I have), they can choose to just use the calculators, or the complete program.
Is what I describe possible?
Well, If you are talking about a pure command-line application: yes.
But, If you are talking about a GUI application: If your application not fully usable from the command line, Go back to the source code and strip down all windows, buttons, UI stuff, etc.. AND make it usable from the command line.
Will I need Azure?
Any cloud provider will do just fine. Depending on the traffic, an old laptop with an internet connection might be enough for your case.
What exactly in Azure will I need (i.e. which products/resources)?
Azure virtual machine with a publicly accessible IP.
Do I need to use the compiled/decompiled version?
Will we need to change any code in the .exe to make this work?
What do I not know that I should know?
Using decompiled version (Source code):
WebAssembly
WebAssembly is a new type of code that can be run in modern web browsers — it is a low-level assembly-like language with a compact binary format that runs with near-native performance and provides languages such as C/C++, C# and Rust with a compilation target so that they can run on the web. It is also designed to run alongside JavaScript, allowing both to work together.
Emscripten
Compile C and C++ code, or any other language that uses LLVM, into WebAssembly, and run it on the Web, Node.js, or other wasm runtimes.
Using compiled verison (executable):
Common Gateway Interface-ish approach
Common Gateway Interface (CGI) is an interface specification for web servers to execute programs like console applications (also called command-line interface programs) running on a server that generates web pages dynamically. Such programs are known as CGI scripts or simply as CGIs. The specifics of how the script is executed by the server are determined by the server. In the common case, a CGI script executes at the time a request is made and generates HTML.
My suggestion would be to use python, PHP or any scripting language you are familiar with to spin up a webserver and execute command based on incoming requests.
Python example:
import subprocess
from flask import Flask
app = Flask(__name__)
#app.route('/calculator') # Accessible from http://[ipaddress]:[port]/calculator
def hello_RedPanda():
command = "..." # as if you are running your program from cmd.
result = subprocess.check_output(command) # execute given command
return result # to your web browser
Once you are done with all the back-end pluming, you can add your buttons and tabs back by rebuilding your UI on the client-side using HTML, CSS and Javascript.
Building the UI in client-side is actually the easy part. The really tricky part in your case is (as I mentioned above) making your application usable from the command line.
See more:
WebAssembly
Emscripten
CGI
A case similar to yours
I want to apologize about my English. It's not very good.
So, I want to make a chat application (pretty much like Facebook's), and after reading a lot I decided to make this chat app with Erlang. After more reading I found out that I can use Yaws server to make a web application with Erlang, but that's all. I still can't even install and configure it well. So my questions are:
Is this information correct? Do I need Erlang / Yaws to create this chat app?
If it's correct, how do I install and configure it under Windows 7? I've tried to simply install "OTP 17.0 Windows 32-bit Binary File" from here http://www.erlang.org/download.html and "Yaws-1.98-windows-installer.exe" from http://yaws.hyber.org/download/, but I think something went wrong, because after I "configure it" at localhost port 8001/8080 or others still nothing happens. So what's next? Do I have to install my code in special directories and/or what do I have to do next ?
In case I finally get a Chat application in Erlang ready, how can It interface with my PHP code? I mean, I already have the PHP project. It is a normal web project with PHP/HTML/Javascript, etc. so my question is, how do I glue these two elements together?(I would like to stress one more time that I have to make something like the Facebook chat).
I'll be thankful for all kind of information, tutorials, books, videos, anything.
I agree with you, Erlang is an excellent option for a chat server. If you want to go for Yaws, check the documentation, it support external scripts via CGI and Websockets. All the information you need to communicate your PHP application with your chat Application is on chapter 9 of yaws' pdf documentation.
There are many ways to create a web application in Erlang. Here are some old examples that use mochiweb:
http://pragprog.com/screencasts/v-kserl/source_code
http://www.chrismoos.com/2009/09/28/building-an-erlang-chat-server-with-comet-part-1/
and a nice example from erlang central
Regarding the PHP integration,there are again, several ways to communicate both. You can integrate the chat with your PHP code using a PHP Erlang bridge
or using websockets
or probably you could try to send your data encoded in JSON from mochiweb using mochijson2.erl and communicate both by HTTP using curl from PHP.
All in all, I would probably also use yaws since is well documented and easy to use. Good luck
I need a web server developed using Haskell to run an old Python CGI application.
Any suggestion is appreciated!
Kazu Yamamoto wrote Mighttpd, a web server built on top of Warp, which has support for running CGI scripts. It will probably do what you're looking for. He also wrote wai-app-file-cgi, which essentially provides the CGI-hosting behavior (as well as static files) as a library.
http://www.mew.org/~kazu/proj/mighttpd/en/
http://hackage.haskell.org/package/mighttpd2
http://hackage.haskell.org/package/wai-app-file-cgi
I'm pretty sure there's no such thing. I can name several web servers written in Haskell, and several frameworks to build web applications using Haskell, but I just checked the general purpose Haskell web servers for whether they host CGI, and none of them seem to so far.
CGI is a pretty simple protocol. It shouldn't be too hard to write a plugin for, say, Warp that supports it, but no one seems to have done so. A good number of Haskell web developers seem to be investing in a thing called WAI. But WAI sort of works in the reverse way to what you're asking it to do. WAI gives Haskell web applications a way to be hosted in almost any web server architecture, much like WSGI does for Python.
You'll notice that there are WAI back ends that enable an appropriately written application to be hosted by a CGI or FastCGI web server. But that allows Haskell to run on CGI, not CGI to run on Haskell.
Without knowing more about the reasons behind your scenario, I have trouble imagining what you're really looking to do. It's a little bit unusual, and I suspect that the unusualness is why there doesn't seem to be any existing solutions to your specific problem.
Perhaps if you tell us more about what you're after, we can suggest alternative approaches that will solve your problem?
I would like to start a new project that consists of multiple tiers, the web tier, event-driven business logic, data processing, etc. I had worked on PHP and Java-based projects for the past few years and speaking from experience, Java (and given the open source libraries to achieve scheduling, ORM, AOP, etc.) is usually a good choice - and of course, you DON'T ALWAYS need a container as different tiers and services can be written with different languages, integrated, together with other processes such as cron jobs.
Now, given that I am starting a new project, I am wondering how would others advice me on the language choice. I am trying to find some answers from Python, Ruby, Erlang Google searches, but certainly this is a good place to collect some good advices and criticisms.
Thoughts?
What I use regularly is the omnipresent LAMP stack (Linux, Apache web server, MySQL database, PHP server logic) and if I need to do something more intensive on the backend, such as processing lots of language data, or running network commands and sorting the output before feeding it back into the system, I use Perl. All of these utilities/languages are available in almost every distribution's repositories, as well as the connector code to use them all together (php5-mysql, for instance, to import PHP functions that allow you to use MySQL).
UPDATE: I would like to add a few ideas to this answer, since someone upvoted it and called my attention to it today. When I wrote this, I was experimenting with a few different technologies, and in many ways I still stand by what I said earlier. LAMP is vastly more mature than any other web platform out there. It's still true that you just can't go wrong starting with this combination.
That being said, a year later, I have been using Nginx and Python (through uWSGI) quite a lot for my personal projects. I think now distro support for both of these technologies is mature enough that people with significant site traffic should genuinely consider switching out Apache with Nginx. It serves static resources FAR faster than Apache. If you want to use PHP, you will probably be using php-fpm to connect PHP to Nginx. If you want to use Python -- which is fast becoming one of my favorite languages, both for its performance and its language features that have grown on me -- you will have a huge choice of options to choose from in order to connect Nginx to Python, but I highly recommend uWSGI for the simple fact that it's tested and it's very fast. As for databasing, I still think MySQL is broadly-powerful enough to suit many different situations. If you disagree with this statement, I'm sure you are experienced enough to search for many thorough resources showing pros and cons for almost any situation.
I was thinking about this the other day and wanted to see what the SO community had to say about the subject.
As it stands right now Common Lisp is getting some attention as a web development platform, and with good reason (of which I'm sure you are already convinced).
I was wondering how one would go about using a library in a shared environment in a similar fashion to PHP.
If I set up something like SBCL as an interperter to interpret FASL files like Python or PHP, what would be the best way to use libraries (like clsql for instance).
Most come as asdf installable libraries, but it would be a stupid amount of overhead to require and install the library each and every time a request is made.
Keeping in mind this is for shared hosting; would it be best to ..
1) Install system wide copies of the libraries for use in applications; reduces space, but there may be problems with using the correct version of the library.
2) Allow users (through a control panel) to install local copies for themselves; more space, no version problems.
3) Tell them to wrap it into a module and load it on demand like Python does (I'm not sure if/how this can be done with Lisp). Just being able to load a library for use would be the best option, but I don't think a lot of them are designed to be used this way.
Anyways, looking to hear your opinions, thanks.
There are two ways I would look at it:
start a Lisp for each request
This way it would be much better that the Lisp is a saved image with all necessary libraries and data loaded. But that approach does not look very promising to me.
run a Lisp and let a frontend (web browser, another web server, ...) connect to it
This way you can either start a saved image or a Lisp that loads a bunch of stuff once and serves the requests.
I like to use saved images/applications in a deployment scenario. They can be quickly started, contain all the necessary software and are independent of library changes.
So it might be useful to provide pre-configured Lisp images that contain the necessary software or let the user configure and save an image.