-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
running a flask server in debug mode breaks hy and drops to Python #329
Comments
So, this happens if you don't use the shim technique that I've used for flask apps - try using a Python shim to import the app and invoke it, so it can re-eval' it and be valid Python :) Worth looking into better solutions to be sure |
Here is a Hy-only workaround: #!/usr/bin/env hy
(import [flask [Flask]])
;; Change the interpreter executable.
;; Werkzeug will now run Hy instead of Python on restarts.
;; This should work as long as "hy" is in the path.
(import sys)
(setv sys.executable "hy")
(def app (Flask __name__))
(setv app.debug True)
(with-decorator (app.route "/")
(defn get-index []
(str "Hello World!")))
;; Run the app, but also restart when this file changes:
(kwapply (app.run) {"extra_files" __file__}) |
This still doesn't work in 2017 with Python 3, but it just crashes now:
|
Hello
I am Marisa, Beluki's wife. I'm sorry but I have to tell you that he died last year.
Sent: Monday, March 27, 2017 at 1:51 AM
From: "Kodi Arfer" <[email protected]>
To: hylang/hy <[email protected]>
Cc: Carlos <[email protected]>, Comment <[email protected]>
Subject: Re: [hylang/hy] running a flask server in debug mode breaks hy and drops to Python (#329)
This still doesn't work in 2017 with Python 3, but it just crashes now:
hy 0.12.1+50.g741b9b9 using CPython(default) 3.6.0 on Linux
=> (import [flask [Flask]])
=> (setv app (Flask "main"))
=> (setv app.debug True)
=> (.run app)
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
/usr/local/bin/python3.6: can't find '__main__' module in '
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
:( |
Thanks for letting us know, Marisa, and sorry if I bothered you. Feel free to mute this thread, as mentioned in the email you got from GitHub. |
He loved his work and one important part of him still lives in the things he made, so thank you to all people that keep that part of him alive.
Sent: Tuesday, March 28, 2017 at 5:20 PM
From: "Kodi Arfer" <[email protected]>
To: hylang/hy <[email protected]>
Cc: Carlos <[email protected]>, Comment <[email protected]>
Subject: Re: [hylang/hy] running a flask server in debug mode breaks hy and drops to Python (#329)
Thanks for letting us know, Marisa, and sorry if I bothered you. Feel free to mute this thread, as mentioned in the email you got from GitHub.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Actually, the same sequence of calls fails with the same error in Python's own REPL. I'm going to close this until somebody can show an example that works in Python but not a recent version of Hy. |
Hello
Carlos (Beluki) died last year, he had cancer, so I cant help you with his work and commentaries. Sorry.
Marisa
Sent: Friday, April 28, 2017 at 12:55 AM
From: "Kodi Arfer" <[email protected]>
To: hylang/hy <[email protected]>
Cc: Carlos <[email protected]>, Comment <[email protected]>
Subject: Re: [hylang/hy] running a flask server in debug mode breaks hy and drops to Python (#329)
Actually, the same sequence of calls fails with the same error in Python's own REPL. I'm going to close this until somebody can show an example that works in Python but not a recent version of Hy.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Setting a Flask app to run in debug mode breaks hy and drops to python.
Steps to reproduce:
$ hy
hy 0.9.11
=> (import [flask [Flask]])
=> (setv app (Flask "main"))
=> (setv app.debug True)
True
=> (.run app)
* Running on http://127.0.0.1:5000/
* Restarting with reloader
Python 2.7.5 (default, Sep 6 2013, 09:55:21)
[GCC 4.8.1 20130725 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
using kwapply give the same result and running directly without setting debug makes the server run
The text was updated successfully, but these errors were encountered: