How to use generic libraries from a Web framework? - apache

OK, I had a look at the memcached module for Nginx but this is clearly not for the faintheart.
Does anyone know about a way to load a library in memory and then use its functions - from a Web server like Nginx, Lighhtpd or Apache?
Example of such libraries abound like JSON parsers, Database client libraries, etc.

Hard to find anything about doing it but those guys have made it pretty easy:
http://dearetc.com/
It takes only one line of code to import a library and all its functions.
Hope it will help others...

Related

What is the best method to set a session cookie using Python 3.x and Cgi on Apache?

I develop in Php, Perl and now am liking Python so much that I want to use it on the web. I can get things working that I need except for a good method for setting/managing sessions. Any help out there? Point me to a library? or ideally post some working python code for my technology stack?
(looking for updated information on how to do this without depending on any framework)

Simple web server to use with IntelliJ on windows?

I am using IntelliJ for a pure Javascript project (some HTML and javascript pages talking to someone else's web services). Right now I am running the page directly from the filesystem, but there are limitations (like not being to write cookies).
Is there a simple web server I can use that will start and stop when I am debugging my project? Like how visual studio will do with ASP.NET or Aptana does?
Thanks!
I have no idea what you are doing, but install XAMPP, it is amazingly simple to use, although it supports PHP/PERL by default, rather than ASP.NET.
if your want to use pure JS&HTML to do something maybe jQuery is a good choise
jQuery with lots of plugins.
if you would like to write some runnable program with Java, please use Tomcat
Hope to help you :)

gwan reverse proxy

I am searching to configure gwan to act as reverse-proxy cache to my web python application.
I could'nt find some example on the web.
Thanks a lot for your examples
Laurent
If your goal is merely to accelerate your Python application then you should just run it from G-WAN (see the hello.py example).
Some (advanced) users have used G-WAN handlers to write their own custom proxy, but G-WAN will document its embedded proxy (and load-balancer) in the following weeks.
It still works without configuration files, so you will not have to learn anything new.
And the competent users will like the ability to personalize the proxy with their own scripts.
There's always a long way between a solution that "runs" and a polished version ready for a wide public.

URL shortening (tinyURL, Bit.ly) application for internal deployment (open source or commercial)

I'm looking for the equivalent of a URL shortening service such as http://bit.ly/ for an internal deployment in our organisation. Anyone know of any open source projects (especially Java ones) or commercial products which I can install internally rather than using an external service?
Thanks!
Shorty : http://get-shorty.com/
But there's several other url shortener .... most of them are in PHP/Mysql.
Don't know if a Java one exist.
http://monkeytooth.net/2010/12/htaccess-php-how-to-wordpress-slugs/
tells you the core basics of how to achieve the concept with PHP and Htaccess building up from there I can say would solely be on your own. However not all to hard a concept in general to build off of if you know php/mysql. That said your not likely to find anything directly built in JavaScript however using this with JavaScript again wouldn't be all that hard a concept. I say your not likely to find one JS based as you need some type of server-side script to communicate with a DB somewhere, where you have all your short URL identifiers, and JavaScript to my knowledge doesn't support directly at least database connectivity. You can go through any means of AJAX to communicate with a server-side script to then do what you want with the JavaScript though.

Apache module for restful services

My objective is create an apache module that will provide RESTful services (i.e., we have some legacy code that controls/queries some networking equipment and we would now like to expose that functionality as a RESTful service). I guess the flow might look something like this:
WebBrowser -- issues RESTful URI---> [Apache (my_module) ] -->..
..---> Interface to existing Legacy code.
I have been mucking around various wikis, blogs, forums, articles etc. but I just can't seem to understand how those RESTful urls will get to (my_module) in apache [you can tell I have never worked with web-servers internals, much less modules, before]. I mean, do I have to edit that httpd.conf file and say something like: Send all urls that look like http://baseurl/restservices/... to my_module. If so, how do I do it?
Also, what will my_module actually get? Does it get the full http request message and it has to parse it like typical CGI programs?
Further, what is the best way for my_module to interact with my legacy code? E.g., Open a TCP connection to it and send messages and write wrapper around legacy code to interpret those messages. Or can my_module directly invoke the functions in my legacy code somehow if I compiled my entire legacy code as a module in apache?
Thanks for any hints. If u know of a good tutorial, please point me to it. I'm looking for a high level overview that will give me the architecture (the developers under me can then follow up on the nitty-gritty details).
I'd write an extension for PHP or Python and use mod_php / mod_wsgi
I think you are approaching this in the wrong way:
Apache modules are not really how you want to handle a URL if your requirements are quote basic. Depending on the language your legacy code is in, I would advise:
Binding its API into a python or PHP module, and have that script called by Apache through normal means. It is also a lot simple (in many cases) to glue a C-call style compiled language to these scripting languages rather than Apache itself.
It also has the advantage of adding an abstractions which allows you to layer additional logic in a scripting language on your core legacy code. You may also want to preprocess data and validate it from the request before handing it into your legacy code.
Both PHP and Python also have RESTful frameworks and utilities.
If you do write an Apache module, then check out Writing Apache Modules with Perl and C
See:
Developing PHP Extensions in C, Extending Python in C or C++ ... also if using Python checkout the WSGI stuff.
I'd agree with Aiden. Writing Apache modules is not for the faint hearted and you definitely don't want to go there unless you absolutely must. You would need to be prepared to become very conversant with how Apache works.
If you still think you need to, then look at:
http://httpd.apache.org/apreq/
This is a library which uses existing Apache Runtime Libraries and which provides higher level functionality for dealing with POST data, cookies etc from C code hooked into Apache via a custom module.
The book Aiden mentions though is a bit dated. Better off getting:
The Apache Modules Book: Application Development with Apache