flexxui / flexx

Write desktop and web apps in pure Python
http://flexx.readthedocs.io
BSD 2-Clause "Simplified" License
3.25k stars 258 forks source link

Requests Blocked by CORS #719

Open i1Fury opened 2 years ago

i1Fury commented 2 years ago

It isn't 100% clear to me how to write a flexx app based around asyncio. I read through:

  1. 373

  2. 408

  3. 413

    Was async ever integrated directly into flexx? I couldn't find the commit :P

i1Fury commented 2 years ago

Update: I managed to get several asynchronous versions working, but I can for the life of me send a request to an external API. For starters, most request packages for python cant be compiled by PScript. Also, flexx uses a browser so it follows CORS. It blocks all requests to other domains. How am I supposed to build my app that relies on an API(like a lot of apps do), if the UI is blended in with the backend? Is there a way I can have a backend to the UI running that isn't compiled by PScript nor blocked by CORS?

gwingnhbc commented 2 years ago

The UI isn’t blended with the backend at all. For my database and rest app my backend parent is a flex py-object which has all the pure python classes in that can’t be handled in pscript, then the browser just sends events to it. Essentially my entire app is in python and just the ui in pscript. You do (or at least did when I wrote my stuff) have to have a py-object root object for this.

From: Fury @.> Sent: 27 January 2022 00:13 To: flexxui/flexx @.> Cc: Subscribed @.***> Subject: Re: [flexxui/flexx] Requests Blocked by CORS (Issue #719)

[EXTERNAL] This message comes from an external organisation. Exercise caution when opening attachments or clicking links, especially from unknown senders.

Update: I managed to get several asynchronous versions working, but I can for the life of me send a request to an external API. For starters, most request packages for python cant be compiled by PScript. Also, flexx uses a browser so it follows CORS. It blocks all requests to other domains. How am I supposed to build my app that relies on an API(like a lot of apps do), if the UI is blended in with the backend? Is there a way I can have a backend to the UI running that isn't compiled by PScript nor blocked by CORS?

— Reply to this email directly, view it on GitHubhttps://github.com/flexxui/flexx/issues/719#issuecomment-1022720886, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHAS4J2MDC3DLBE6YBTVRODUYCE2PANCNFSM5M2RPECA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.***>

National House-Building Council (00320784), NHBC Services Limited (03067703) and NHBC Building Control Services Limited (01952969) are registered in England and Wales with their registered office at NHBC House, Davy Avenue, Knowlhill, Milton Keynes, Buckinghamshire MK5 8FP.

National House-Building Council is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority.

This email message (including any attachments) is intended solely for the addressee and may contain confidential, proprietary or legally privileged information. If you have received this message in error, please send it back to us, and immediately and permanently delete it. Do not use, copy, disseminate, distribute or disclose the information contained in this message or in any attachment. We have taken all reasonable precautions to ensure that no viruses are transmitted with this message. However, we can accept no responsibility for any loss or damage resulting directly or indirectly from the use of this e-mail or its contents. Incoming and outgoing e-mails are subject to scanning and may be intercepted by our e-mail administrators.

For information about how we process data please see our privacy policy at www.nhbc.co.uk/Legal/PrivacyPolicy and for terms of use please see the terms at www.nhbc.co.uk/Legal.

i1Fury commented 2 years ago

I switched to Neutralino using a python backend extension, i like it a lot better than Flexx at it's current state after messing around with Flexx for about 6h. I am gonna keep a close eye on this project because when it comes out of beta it'll be fire.

almarklein commented 2 years ago

I managed to get several asynchronous versions working, but I can for the life of me send a request to an external API. For starters, most request packages for python cant be compiled by PScript. Also, flexx uses a browser so it follows CORS.

The tricky part with Flexx is that both the server and client code are in Python, so the look alike a lot. You have to be careful to separate that in your application. Also see the word of caution in the readme. On the server side (e..g. in PyWidget's) you can use the Python async constructs, and you could send requests with e.g. responder or httpx (both are async). On the client side (in most other widgets) you're actually writing JavaScript (via PScript), and you can use JavaScript requests. And yes, you are subject to the browser's security constraints.

I am gonna keep a close eye on this project because when it comes out of beta it'll be fire.

To be honest, I am not actively developing Flexx anymore, so it will probably take a new developer to pull this out of beta, if ever.