title: How do you compile a flask app with cython?
body: <p>I have a Python flask app that I need to compile using cython.
  Following <a href="https://medium.com/@xpl/protecting-python-sources-using-cython-dcd940bb188e" rel="noreferrer">this guide</a>, I can compile a simple python application, but when I do the same thing to a simple flask app:</p>
  
  <pre><code>#!/usr/bin/env python2
  
  from flask import Flask
  
  app = Flask(__name__)
  
  @app.route("/")
  def index():
      return "hello"
  
  if __name__ == "__main__":
      app.run(host='0.0.0.0', port=8000)
  </code></pre>
  
  <p>It seems to compile fine, but when I try to run it, I get this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./run.py", line 3, in &lt;module&gt;
      from app import main
  ImportError: cannot import name main
  </code></pre>
  
  <p>When I try to run main.py.</p>
  
  <p>My compile.py looks like this:</p>
  
  <pre><code>#!/usr/bin/env python2
  
  from distutils.core import setup
  from distutils.extension import Extension
  from Cython.Distutils import build_ext
  ext_modules = [ 
      Extension("app",  ["app.py"]),
  ]
  setup(
      name = 'My Test Website',
      cmdclass = {'build_ext': build_ext},
      ext_modules = ext_modules
  )
  </code></pre>
  
  <p>My main.py looks like this:</p>
  
  <pre><code>#!/usr/bin/env python2
  
  from app import main
  main()
  </code></pre>
  
  <p>Does flask use some features that can't be compiled? Or am I doing it wrong?</p>