Note that there are some explanatory texts on larger screens.

plurals
  1. PODeploying a Flask application using Paste
    primarykey
    data
    text
    <p>I'm building a web service using Flask and I'm trying to deploy a simple "Hello, World" app using Paster. I'm having trouble get everything configured to work together though. I've seen the Google hit about running Flask with paste using virtualenv and zcbuildout, but that seems like it's overkill for a pretty basic application. Right now, when I try to load a URL with my app, I get this error:</p> <pre><code>Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/paste/httpserver.py", line 1068, in process_request_in_thread self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 639, in __init__ self.handle() File "/usr/lib/python2.7/dist-packages/paste/httpserver.py", line 442, in handle BaseHTTPRequestHandler.handle(self) File "/usr/lib/python2.7/BaseHTTPServer.py", line 343, in handle self.handle_one_request() File "/usr/lib/python2.7/dist-packages/paste/httpserver.py", line 437, in handle_one_request self.wsgi_execute() File "/usr/lib/python2.7/dist-packages/paste/httpserver.py", line 287, in wsgi_execute self.wsgi_start_response) AttributeError: GraffitiApp instance has no __call__ method </code></pre> <p>My application configuration looks like:</p> <pre><code>[DEFAULT] loglevel = WARN browser_cache_ttl = 30 [app:main] use = egg:GraffitiService [server:main] use = egg:Paste#http host = 0.0.0.0 port = %(graffiti_port)s </code></pre> <p>My application code looks like:</p> <pre><code>from flask import Flask app = Flask(__name__) app.debug = True class GraffitiApp: @app.route('/') def hello_world(): return "Hello World!" @app.route('/other') def other_page(): return "Other page!" def main(): app.run(debug = True) if __name__ == "__main__": app.run(debug = True) </code></pre> <p>Do I need to create a <code>__call__()</code> method and map whatever URL was passed to the appropriate function, or is there a change I need to make to my configuration?</p> <p><strong>EDIT</strong></p> <p>I'm using a factory named main.py as a result of errors I was getting about not finding an entry point named "main":</p> <pre><code>import logging from graffiti import GraffitiApp def make_app(globalArgs, **localArgs): loglevelname = globalArgs.get("loglevel", "INFO").lower() if loglevelname == 'critical': loglevel = logging.CRITICAL elif loglevelname == 'debug': loglevel = logging.DEBUG elif loglevelname == 'error': loglevel = logging.ERROR elif loglevelname == 'fatal': loglevel = logging.FATAL elif loglevelname == 'info': loglevel = logging.INFO elif loglevelname == 'warn' or loglevelname == 'warning': loglevel = logging.WARN else: loglevel = logging.NOTSET loglevelname = 'notset' FORMAT = "%(asctime)s %(name)s %(levelname)s %(message)s" logging.basicConfig(format = FORMAT, level = loglevel) logging.info("Log level set to %s" % (loglevelname.upper())) return GraffitiApp() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload