Integrating external web application 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/.
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).