I have an existing web application written in Flask. I want to create a Drupal site that integrates this existing web application, so that the existing webapp will just be a back end, and the Drupal site will contain all the forms that submit data to the web app and displays the results from the web app. I was thinking that Drupal Services could do that for me, but it looks like it is more for the reverse use case: to use an external web app as front end to Drupal..

So my question is: What is the best way of using Drupal as a front end to an existing web application?

Or is this even possible?

Some extra info about the web app:

  • Web app is written in Python/Flask
  • It is a web shop like application that allows users to search for products based on various criteria.
  • Web app is highly modular and cleanly split into views, forms, model, so it would be fairly straight forward to change the web app in order to present data via another protocol/API. I figure it would be possible to create new views that present the data in JSON or something like that and I hope that Drupal can somehow pick that up and display it in its templates.
  • Database is PostgreSQL
  • Frameworks used: Flask, SQLAlchemy, WTForms

Update 2015-05-15: More details

I have considered using Drupal Services because it sounded like it was an API for this, however, it turned out that Services solves the reverse problem: Makes it possible to use an external app as front end for a Drupal site.

How I think this could be done: Make the existing Flask webapp into a REST server allowing the Drupal site to send requests to the app for search queries, product displays, etc. So the external app will respond with some JSON that contains all the content and URLs to images, etc. In Drupal there will have to be a template for each view on the external app. E.g.:

  • Search form
  • Search result
  • Product display
  • etc.

I have zero experience in doing this stuff from Drupal. I have some experience with using Drupal. But mostly vanilla Drupal.

I was hoping that there were either a plugin or framework or something that would make it easier to do this. that is something that will make it easy in Drupal to create the following kinds of elements:

  • A form/template that upon submit sends request to REST service and displays results (e.g. serach)
  • A template that renders a page according to some JSON data gotten from a RESTful service.

Regarding PDO, I am not sure what that is. I am using PostgreSQL. I was not planning on letting Drupal access the external web app's database directly. That would essentially require me to reimplement the entire application in Drupal.

As mentioned above, the external app is written in Flask. Flask is a Python framework for making web applications. For short introduction, see http://flask.pocoo.org/.

  • Welcome to Drupal Answers :) I've removed the part of your question asking for comparisons/recommendations for CMSs, it's not something we do here. Regarding the rest of the question, what approaches have you considered so far, which have you discounted and why, etc? I don't mean Drupal-based approaches specifically, but at the basic level you're going to need an AJAX framework that connect to (presumably) a REST server. Knowing which framework/approach you want to use will make it much easier to tell you how you can integrate that into Drupal
    – Clive
    May 14, 2015 at 12:01
  • Or were you hoping that a generic module solution already exists for this? I'd be surprised if there was, but you never know
    – Clive
    May 14, 2015 at 12:02
  • Apart from Clive's comments, it may help to also include info about the database format involved. Like is it some PDO compliant DBMS? Maybe a few words to explain "Flask" (or a relevant hyperlink you'd suggest to find out more info about that, like is flask.pocoo.org a good place to find out)? May 14, 2015 at 12:12
  • Clive, by AJAX framework, do you mean that this could be handled entirely on the client side? E.g. by making special templates in Drupal that uses af Javascript library to submit forms to and retrieve results from the external webapp via a JSON / REST API?
    – Thomas
    May 18, 2015 at 13:38
  • I have looked at REST Client: drupal.org/project/rest_client. This seems to be unsupported. Is there an up to date and supported alternative? It sounds like something like REST client will do some of what I want.
    – Thomas
    May 18, 2015 at 13:50

1 Answer 1


About What is the best way of using Drupal as a front end to an existing web application?: I leave it to others to decide if it would be the "best" way, but "a" way to do so is to continue to use your existing web application for maintaining the data of it, and then use Drupal as a frontend to actually visualize those data (read only operations).

Assume the DBMS involved is some type of PDO compliant DBMS, e.g. MySql (the question currently does not provide details on that). So similar to what is described in Python Web Application Development Using Flask and MySQL. In that case the Forena module would be a perfect fit to get the job done, i.e. build reports and/or charts about data stored in your existing web application. Here is a quote about Forena:

... built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.

Possible DBMSs that could fit this approach are the Drupal DB itself (of course), but also MySQL, Oracle, MS SQL, Postgress, Sqite, anything PDO compliant.

The advantage of this approach is that you get lots of Drupal features avilable, while the "bacckend-part" of your application continues to be the applicationn you already have (you don't loose the investements made in that).

  • I was hoping that I would be able to use the existing web application as a RESTful web service and just have Drupal display the data that the REST service provides via and API. Isn't that how people integrate with a lot of big web applications such as Google Maps, etc. already?
    – Thomas
    May 15, 2015 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.