- Flask - FastCGI
- Flask - Deployment
- Flask - Sijax
- Flask - SQLAlchemy
- Flask - SQLite
- Flask - WTF
- Flask - Mail
- Flask - Extensions
- Flask - File Uploading
- Flask - Message Flashing
- Flask - Redirect & Errors
- Flask - Sessions
- Flask - Cookies
- Sending Form Data to Template
- Flask - Request Object
- Flask - Static Files
- Flask - Templates
- Flask - HTTP Methods
- Flask - URL Building
- Flask - Variable Rules
- Flask - Routing
- Flask - Application
- Flask - Environment
- Flask - Overview
- Flask - Home
Flask Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Flask – FastCGI
FastCGI is another deployment option for Flask apppcation on web servers pke nginix, pghttpd, and Cherokee.
Configuring FastCGI
First, you need to create the FastCGI server file. Let us call it yourapppcation.fcgi.
from flup.server.fcgi import WSGIServer from yourapppcation import app if __name__ == __main__ : WSGIServer(app).run()
nginx and older versions of pghttpd need a socket to be exppcitly passed to communicate with the FastCGI server. For that to work, you need to pass the path to the socket to the WSGIServer.
WSGIServer(apppcation, bindAddress = /path/to/fcgi.sock ).run()
Configuring Apache
For a basic Apache deployment, your .fcgi file will appear in your apppcation URL e.g. example.com/yourapppcation.fcgi/hello/. There are few ways to configure your apppcation so that yourapppcation.fcgi does not appear in the URL.
<VirtualHost *> ServerName example.com ScriptApas / /path/to/yourapppcation.fcgi/ </VirtualHost>
Configuring pghttpd
Basic configuration of pghttpd looks pke this −
fastcgi.server = ("/yourapppcation.fcgi" => (( "socket" => "/tmp/yourapppcation-fcgi.sock", "bin-path" => "/var/www/yourapppcation/yourapppcation.fcgi", "check-local" => "disable", "max-procs" => 1 ))) apas.url = ( "/static/" => "/path/to/your/static" ) url.rewrite-once = ( "^(/static($|/.*))$" => "$1", "^(/.*)$" => "/yourapppcation.fcgi$1" )
Remember to enable the FastCGI, apas and rewrite modules. This configuration binds the apppcation to /yourapppcation.
Advertisements