how to run a standalone python script via gunicorn/wsgi?How can I represent an 'Enum' in Python?Is there a way to run Python on Android?How do I copy a file in Python?How can I safely create a nested directory?How to get the current time in PythonHow can I make a time delay in Python?How can you profile a Python script?How do I check what version of Python is running my script?How do I get the number of elements in a list?How do I concatenate two lists in Python?

LM324 - Issue with output in negative feedback

Fix Ethernet 10/100 PoE cable with 7 out of 8 wires alive

How to stop the death waves in my city?

Why is STARTTLS still used?

Where's the mandatory argument of sectioning commands

Convert a string of digits from words to an integer

Why aren't faces sharp in my f/1.8 portraits even though I'm carefully using center-point autofocus?

Where to find the Arxiv endorsement code?

Does variance make sense in a fully immutable language?

What should I consider when deciding whether to delay an exam?

Detail vs. filler

Smallest number containing the first 11 primes as sub-strings

"until mine is on tight" is a idiom?

How to model regression with an asymmetric loss function?

Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?

Problematic Nature of Views

Why does my browser attempt to download pages from http://clhs.lisp.se instead of viewing them normally?

Can I exile my opponent's Progenitus/True-Name Nemesis with Teferi, Hero of Dominaria's emblem?

Installation of ImageMagick software fails with "configure: error: libltdl is required"

What are examples of EU policies that are beneficial for one EU country, disadvantagious for another?

Role of "einfach" in a certain context

ZFS inside a virtual machine

お仕事に学校頑張って meaning

The TI quad-XOR gate acts as it is short circuit



how to run a standalone python script via gunicorn/wsgi?


How can I represent an 'Enum' in Python?Is there a way to run Python on Android?How do I copy a file in Python?How can I safely create a nested directory?How to get the current time in PythonHow can I make a time delay in Python?How can you profile a Python script?How do I check what version of Python is running my script?How do I get the number of elements in a list?How do I concatenate two lists in Python?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















i have a standalone web-based python script, rpc.py which is built as a cgi script for direct access through a web server. it is handling all http headers, requests and what have you got. running a web server, with mod_cgi, rpc.py can be executed as:



http://127.0.0.1/rpc.py?service_id=atestservice.



to avoid the cgi approach in production i want to use wsgi. i have no experience with wsgi from before. however, after some research, it seems like the use of nginx with gunicorn is a good option. hence, my question: is there a simple way to wrap rpc.py inside a wsgi app, and just pass on all request parameters?



pseudocode of wanted result:



def app(environ, start_response):
data = execute_as_web_request(rpc.py, get_parameters)
return iter([data])


what is the best approach in such a situation? is it rewriting rpc.py into a wsgi app? or, maybe just run this script via fastcgi?










share|improve this question
































    1















    i have a standalone web-based python script, rpc.py which is built as a cgi script for direct access through a web server. it is handling all http headers, requests and what have you got. running a web server, with mod_cgi, rpc.py can be executed as:



    http://127.0.0.1/rpc.py?service_id=atestservice.



    to avoid the cgi approach in production i want to use wsgi. i have no experience with wsgi from before. however, after some research, it seems like the use of nginx with gunicorn is a good option. hence, my question: is there a simple way to wrap rpc.py inside a wsgi app, and just pass on all request parameters?



    pseudocode of wanted result:



    def app(environ, start_response):
    data = execute_as_web_request(rpc.py, get_parameters)
    return iter([data])


    what is the best approach in such a situation? is it rewriting rpc.py into a wsgi app? or, maybe just run this script via fastcgi?










    share|improve this question




























      1












      1








      1








      i have a standalone web-based python script, rpc.py which is built as a cgi script for direct access through a web server. it is handling all http headers, requests and what have you got. running a web server, with mod_cgi, rpc.py can be executed as:



      http://127.0.0.1/rpc.py?service_id=atestservice.



      to avoid the cgi approach in production i want to use wsgi. i have no experience with wsgi from before. however, after some research, it seems like the use of nginx with gunicorn is a good option. hence, my question: is there a simple way to wrap rpc.py inside a wsgi app, and just pass on all request parameters?



      pseudocode of wanted result:



      def app(environ, start_response):
      data = execute_as_web_request(rpc.py, get_parameters)
      return iter([data])


      what is the best approach in such a situation? is it rewriting rpc.py into a wsgi app? or, maybe just run this script via fastcgi?










      share|improve this question
















      i have a standalone web-based python script, rpc.py which is built as a cgi script for direct access through a web server. it is handling all http headers, requests and what have you got. running a web server, with mod_cgi, rpc.py can be executed as:



      http://127.0.0.1/rpc.py?service_id=atestservice.



      to avoid the cgi approach in production i want to use wsgi. i have no experience with wsgi from before. however, after some research, it seems like the use of nginx with gunicorn is a good option. hence, my question: is there a simple way to wrap rpc.py inside a wsgi app, and just pass on all request parameters?



      pseudocode of wanted result:



      def app(environ, start_response):
      data = execute_as_web_request(rpc.py, get_parameters)
      return iter([data])


      what is the best approach in such a situation? is it rewriting rpc.py into a wsgi app? or, maybe just run this script via fastcgi?







      python python-3.x nginx gunicorn wsgi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 20:23







      klevstul

















      asked Mar 28 at 18:56









      klevstulklevstul

      501 silver badge7 bronze badges




      501 silver badge7 bronze badges

























          0






          active

          oldest

          votes














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404993%2fhow-to-run-a-standalone-python-script-via-gunicorn-wsgi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404993%2fhow-to-run-a-standalone-python-script-via-gunicorn-wsgi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript