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
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/.