


In my earlier post we have gone thru step by step instructions to install Apache web server from scratch and host https enabled website into it. In this blog we will go thru the step by step instructions to host Python Flask APIs in Apache Web server. This is a requirement when you want to integrate front end Application(Angular SPA) with Azure AD because Angular SPA should call API hosted in Https Endpoint to work with Azure AD. In the production environment you can not use Flask to host your API and you definitely need a production web server like Apache or Gunicorn. Flask is good for development purpose but when you move to production you need to host it in Web server. Here is the example Architecture where it can be helpful.
Step 1.Deploy Mod_ssl and apache web server. Please refer to my earlier post.
The Apache HTTP Server has been the most commonly deployed web server on the Internet for 20+ years. Nginx is the second most commonly used server for the top 100,000 websites and often serves as a reverse proxy for Python WSGI servers. Caddy is a newcomer to the web server scene and is focused on serving the HTTP/2 protocol with HTTPS. Apache TinkerPop: A Graph Computing Framework. The Benefits of Graph Computing. A graph is a structure composed of vertices and edges.Both vertices and edges can have an arbitrary number of key/value-pairs called properties.
On the other hand, the AMPPS web server includes Python if you decided to use it. XAMPP stands for Cross-Platform (X), Apache (A), MySQL (M), PHP (P) and Perl (P). It is a simple, lightweight Apache distribution that makes it extremely easy for developers to create a local web server for testing purposes.
Step 2: Install Mod_wsgi module.
Please note that mod_wsgi module is required to host Flask API into Apache web server.
Python On Apache Web Server Interview
Step 3:Perform Module configuration.
Add the below lines in the ssl.cnf ( SSL config file).Please refer to my earlier post to know what is ssl.cnf’s role here.
Step 3: Test the API call my using https://serverhostname/apiname. It should work perfectly.
Hope this post was useful.
The Web Server Gateway Interface (WSGI in short) is a simple method for the web servers to forward requests to the web applications or frameworks written in the Python. The WSGI is the specification, which describes how a web server communicates with the web applications.
The mod_wsgi is an Apache module used to serve Python scripts over HTTP. This tutorial helps you to how to install the Apache mod_wsgi module on Ubuntu 20.04 system.
Prerequisites
Login to your Ubuntu 20.04 server console with sudo privileged account.
Step 1 – Installing Python
You must have installed required Python version on your system. For the Ubuntu systems, you can use apt package manager to install Python on your system.
Step 2 – Install Apache with mod_wsgi Module
Next, you need to install Apache web server including Apache utility package and mod_wsgi Python module on your system. To install these packages run the following commands.
Python On Apache Server
After installation, restart Apache service to reload all modules.
Step 3 – Setup Apache for WSGI
Now, we will create a sample python script to serve via mod_wsgi Apache module. Create a Python script and edit in your favorite text editor:
Add the following content:
