Can any Haskell web server run Python CGI apps? - haskell

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?

Related

Why all those new languages have their own web server?

I am kinda old school and the first programming language for web I saw was PHP, and everybody uses it with Apache. At that time, I also knew ASP, which were used along with Microsoft IIS and, later, ASP.NET, that runs over IIS, as well.
The time passed, I went to the ERP world and, when I came back (few months ago), I knew Golang and Node.js and for my surprise they have their own web servers.
I can see many advantages in the builtin web servers, but, every application needs to rewrite their web server rules (I faced that recently when I needed to setup a HTTPS server using Express.js).
After some hard work to understand all the nuances of the HTTP protocol, I asked myself: and if I am doing it in the wrong way? If all the permissive rules that I created in my dev server go to production? Maybe this is an useless concern. But maybe I am creating a fragile server that could be exploited by a naive hacker.
Using a server like Apache it is harder to misuse security rules, because there are settings for development and production environments that are explicit. If the rules are hardcoded (as they are in Node or Go), an unaware developer can use development rules in production and nobody is going to see it before the stuff happens.
Any thoughts?
web server focuses on the speed capacity and the caculating capacity. No matter how good java or php web is or how many old companies put them in use, as long as a new language can provides a faster speed and better capacity such as go, more programmer would go for it.
by the way, to run a web server in go is really such an easy thing.It's faster building and slightly running.And the routine in go helps the web server beter serves milions of client requests,Which old web language can hardly do it.
You can still use nginx or apache in front of your golang gateway for many reasons including tls termination.
But service to service communication might be nice to communicate directly to services and the golang http webserver is fast. It also supports http2 out of the box. Go leverages its "goroutines" to reduce overhead from the os to handle many requests at once.
Node.js and Golang do not have their web server, these are just some lib packages implement http-protocols and open some ports to provide services.
Like Spring web.
Nginx/IIS/Apache are true server, web server just a component of them.
I think Spring should meet the full application scenarios, include /gateway/security/route/package/runtime manage/ and so on.
But when we has some different language platform, then we need nginx/apache/spring gateway/zuul/or others to route them.

What is the best Server to host a Haskell webpage (HSP)?

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.

Language Choice for Multi-Tier/Multi-Threaded/Event-Based Container

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.

Good language to learn in order to build small websites

I want to start building websites and charging people for them!
My problem is that the stack that know well does not lend itself to quick development, or cheap hosting.
I am looking for languages that satisfy the following criteria:
Fast to develop in
Can find cheap hosting for it
Bonus points if it can also be 'enterprisey'
Fast to develop in: When building a web application, what makes a language quick to develop in is a framework. Some languages that have a very robust web application framework include: Java, Ruby, PHP, Python.
Can find cheap hosting for it: PHP is probably the most ubiquitous language in terms of web hosting support. More web hosts are adding support for Ruby and Python frameworks such as Rails and Django, though.
Bonus points if it can also be 'enterprisey': Not quite sure what you mean by that. But for some reason Java comes to mind.
Use a framework such as drupal
I have done a few sites on the side as well and have wanted cheap hosting, speedy development etc.
I ended up just using GAE simply because:
You can use either Python/Java (both are widely used)
You can used current web frameworks (Django etc.)
It's free hosting (until the site starts hitting the free quota limits)
Deployment is easy
One downside could be that you're tied to BigTable so if you wanted to move your site to something else you might have some work there.
(I'm not advocating for GAE, just have used it for a few sites and it has worked pretty good for what was required)
I'd recommend PHP. It's well supported, quick to learn, and relatively common among small web hosts.
Your requirements are super-vague... But to recommend something different, try out the Ruby on Rails - it is really fast, can get enterprisey and there is at least heroku.com for hosting.

Web programming language

I want to go learn web programming,but besides names and a little of html I don't know anything.So I ask you what programming languages you recommend,why,what can be done with it,tools to learn ,etc.I don't know if it matters but I program in a Linux enviroment(Ubuntu).
I don't want to do hardcore web programming ,I only want to be able to develop complete websites and understand network concepts.
Well, most cheap/free web hosts support PHP, MySQL, and most browsers support Javascript.
Target those and you'll be on a reasonably good path.
Some support Ruby and Python, and you might choose that path if you want to learn those languages.
Good luck!
-Adam
Definitely start with HTML, and basic CSS. These are the core of web programming, and you need to understand them well to do anything of consequence.
Once you've got those down, you'll want to move on to a server-side language. The easiest is PHP, but be careful of picking up bad habits, since it's a loose environment; if you stick with PHP, you'll eventually want to use it with an MVC framework such as CodeIgniter, which encourage separating presentation and logic. To get a little more advanced, you can also try Python or Ruby. Get yourself some server space to mess around with; most shared hosting plans are $5-10/month.
For Javascript/AJAX, you'll probably want to start by using Firebug or Firefox's DOM inspector to learn the relationship between the HTML of a page and the DOM object which Javascript uses to interact with it. Once you understand how the DOM works, toy around with jQuery to start doing useful (and fun!) stuff.
You'll also eventually want to learn MySQL (or a similar SQL variant), but that can probably wait, since you can do lots of interesting things without tackling database stuff.
Above all, be patient and persistent, and make use of every resource at your disposal: books, Google, Stack Overflow, and cheat sheets.
Ruby all the way. It's exactly what you need if you're interested in web dev and completely starting from scratch programming-wise. From the basics of Ruby it's pretty easy to get into Rails, which is a very beginner-friendly web framework.
Many great books on Amazon (look for the highest rated of course) on both Ruby and Rails.
Great starting point for links:
http://www.ruby-lang.org/en/documentation/
As well check out Learn to Program
Now get learnin'.
Google App Engine offers free hosting for applications that do not exceed the specified limits. The server-side language is Python, the client-side language is JavaScript inside Django templates. Everything has worked nicely for me in Ubuntu 8.10.
GREAT Question,
a couple of years ago I was in the same place -
What HONESTLY Helped me was using Dreamweaver, I set it in split mode and started watching the code
I used this and started delving into the PHP Application world and could see what was going on (sort of)
I know you can use dreamweaver with wine on the linux, and it can help you do a TON
granted if you continue it has the potential to limit you to the dreamweaver world... but can help you learn and create at the same time
(I build full php apps from scratch now with a notepad... but I started with DW)
The question I'd have is what kind of scale on web programming are you wanting to do? If it is small stuff then the LAMP stack would be my suggestion while if you want to get more into 3-tier architecture then Java or ASP.Net may be worth getting into for middleware or business logic code.
With the exception of the reference to the LAMP stack above, there has been no Perl recommendations. I like Perl as it is easy enough to build a fairly full featured web application (using CGI, or mod_perl). Of course, you are going to have to learn HTML/CSS if you are going to do anything on the web. I feel Perl is a good choice for web development as it is fairly robust and full featured with all of the modules available on CPAN. Combine with an application framework like CGI::Application or Catalyst and you can build sophisticated web apps in a short amount of time. Also, using a tool like XAMPP can help as you won't have to worry about web server or database cofigurations to get started.

Resources