Skip to content

Instantly share code, notes, and snippets.

@Karunamon
Last active January 25, 2016 00:15
Show Gist options
  • Save Karunamon/bbdd7c5b7625198a634b to your computer and use it in GitHub Desktop.
Save Karunamon/bbdd7c5b7625198a634b to your computer and use it in GitHub Desktop.
Flask Class Shenanignas
from flask import Flask
import thread
web = Flask(__name__)
class AwesomeClass(object):
def __init__(self):
thread.start_new_thread(web.run, ())
self.some_important_var = "spam"
@web.route('/order/<args>')
def some_web_function(self, args)
return "Your order: " % self.some_important_var + args
# wget http://localhost:5000/order/eggs
# Oh noes!
# TypeError: some_web_function() tkaes exactly 1 argument (0 given)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment