hug icon indicating copy to clipboard operation
hug copied to clipboard

how to configure hug application in PyCharm

Open chopanpma opened this issue 9 years ago • 6 comments

Hi, I am new to python and I have tried to configure my hug application to use PyCharm for debugging, however I have not been able to determine the startup script that work with PyCharm . 2017-02-21 10_57_33-run_debug configurations

chopanpma avatar Feb 21 '17 15:02 chopanpma

Unfortunately with the way hug code is run (hug -f FILE) you have to attach the debugger to the process (Unless some other undocumented way exists), first step would be making the run process more convenient, I suggest creating a new External Tool preset like this: hug

Makes it a bit simpler to get running, once its running you would then use the Run > Attach to local process feature. Keep in mind it apparently only works for Python 3.4.4 and older.

Evolution0 avatar Feb 22 '17 14:02 Evolution0

Thanks,

On Feb 22, 2017 9:20 AM, "Anthony Forsberg" [email protected] wrote:

Unfortunately with the way hug code is run (hug -f FILE) you have to attach the debugger to the process, first step would be making the run process more convenient, I suggest creating a new External Tool preset like this: [image: hug] https://cloud.githubusercontent.com/assets/1984403/23215308/e29d8a66-f8df-11e6-9a9b-0bbeb33970f7.PNG

Makes it a bit simpler to get running, once its running you would then use the Run > Attach to local process feature. Keep in mind it apparently only works for Python 3.4.4 and older.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/timothycrosley/hug/issues/460#issuecomment-281681689, or mute the thread https://github.com/notifications/unsubscribe-auth/ALRjVfY3ib03lSXIeqNy4C7BQLi_GOycks5rfEQVgaJpZM4MHgIO .

chopanpma avatar Feb 22 '17 14:02 chopanpma

If it helps, this alternative approach also seems to behave like any other wsgi server for PyCharm, and happily handles debugging, code coverage etc. Setup is as simple as pointing PyCharm at this server. Can vouch for it on Python 3.5, 3.6: https://github.com/timothycrosley/hug/issues/450#issuecomment-279685321

davidhyman avatar Feb 27 '17 12:02 davidhyman

Closing this as it seems to have been satisfactorily answered. Thanks! ~Timothy

timothycrosley avatar Apr 17 '17 04:04 timothycrosley

@davidhyman "Setup is as simple as pointing PyCharm at this server."

How do you do this? If the comment you've linked to is related, I'm not following it.

joshnoe avatar Sep 26 '17 00:09 joshnoe

FWIW here's what I ended up doing to run/debug from PyCharm. api is a file with hug routes defined.

from werkzeug.serving import run_simple

import api


def create_app():
    return api.__hug_wsgi__


app = create_app()

if __name__ == '__main__':
    run_simple('0.0.0.0', 5000, app, use_reloader=True, use_debugger=True, threaded=True)

timwah avatar Jun 22 '18 23:06 timwah