Anyone know a web framework for Python? :-)

I was just thinking of how I could get my python code in a format easily consumable by my coworkers as we try to get network automation and SDA off the ground. Listening to the “Talk Python to me” podcast on the way to work, and this high energy guy (Meredydd) talking about Skulpt, and how he is using it in Anvil.

So here I am!

I’m a bit new to python, I basically have to look things up or copy paste from previous code at this point, but I have written a few thousand lines over the last month. Our company is deploying Openshift, so my idea is to run libraries in Openshift, and front end it with Anvil.

Trying to work out how to upload an excel file to Anvil and pass it to my library in OpenShift. I know excel is not exactly the best format to work with, but our leasing company gives it to us in excel, and I’m currently parsing that with openpyxl, and calling ServiceNow rest API’s to import the assets.

Maybe someone has an example of passing a file to the back end offsite over the uplink? Currently I’m stitching a few documents together to try to understand the process, but since they keep referencing media files its a bit confusing, as my .xlsx is not exactly a media file.

Anvil might be a great platform to front end basic system automation scripts. I saw there is a tutorial on dashboards, so thats on my todo list :wink:

And the BIG idea down the road… Well all my Cisco routers and switches have python installed, that I can kick off on a schedule. Wouldn’t be too hard to have them uplink and report statistics back to Anvil Database, or even attach passive and wait for a query. You could maybe provide a user self service portal that lets them look at their switch port statistics instead of calling the Network team out just to find they are getting a windows update they didn’t know about.

There are web frameworks (here’s a few https://wiki.python.org/moin/WebFrameworks), but watch out for the learning curves. They generally require that you understand many additional languages: CSS, HTML, SQL, JavaScript, …

My whole reason for using Anvil is to bypass all those ugly details, and focus (as much as possible) on the actual problem/solution, not the framework.

3 Likes

@ccie6145

Check out this post … it passes a CSV file … but it might connect a few dots

anvil is THE web framework for Python. ignore what anyone says otherwise, their opinion is outdated.

9 Likes

I agree. Anvil is the best way to get a workable product running without the hassle of wiring a bunch of things up. Love it!

It’s a shame though that you can’t get a full screen mode for the code editor for a platform that centralizes every single aspect of development… This has been mentioned and suggested time and time again and ignored by the development team.

2 Likes

what do you mean full screen mode? probably requires a lot of effort for something that would be a ‘nice to have’

The screen with “Design” and “Code” tabs on it. There should be a button to expand that entire screen to take up the entire page, or to minimize it. If that requires a lot of effort, there’s something wrong with the implementation of Anvil.

Reading code is at least 80% of development work, so I disagree that this is just a “nice to have”.

1 Like

The developers are not ignoring feature requests just because something has not been implemented. Based on how amazing this product is already, I personally trust that they are making reasonable decisions concerning feature requests, and I am certainly reluctant to say, “I know better”. Despite not having a full-screen editor, I continue to develop at the speed of thought (thanks to Anvil), and so I do my best to remain patient about getting more.

1 Like

True, the lack of implementation of a feature doesn’t imply that the they’re not working on it. It’s just frustrating to have this (seemingly simple to implement, high value) feature requested and no idea if it’s even in the pipeline.

Of course since the development process is mostly closed, there’s really no other options other than wait and complain, or to just hope and pray that it happens. This lack of transparency is frustrating especially as a developer who is completely dependent on this product to build and maintain a business.

All that being said, the customer support on the forums is good and overall I love the product.

Thanks for the Tips on the file transfer, much appreciated I’ll look at the links!

Sorry for the title, I assume everyone would know I was joking. Of course Anvil is the web framework for Python!

1 Like

I work with a 40" monitor, and I still am annoyed by the waste of real estate by the Code Snippets frame.

One (ugly) workaround is to press F12 and type this in the console:

  • Hide the Code Snippets frame:

    $(".main-panel").css({"right":"0"})
    
  • Show the Code Snippets frame:

    $(".main-panel").css({"right":"33%"})
    

I don’t know if this will have any side effect, I hope not.

1 Like

For an Excel upload, see: Importing existing data into Data Table

1 Like

Well i know there are other python web frameworks that people enjoy. I myself am just a toxic anvil maximalist.

2 Likes

I discovered Anvil via the podcast too and had to check it out. Haven’t turned back since.

2 Likes

I tried to have a go at a hack when I saw this post…
Hack for Full Screen Editor - hide code snippets

Haha, niiiice. I hope they end up adding this kind of functionality soon :slight_smile:

Yes Anvil is framework agnostic, kind of

Pro Tip: Whenever you see Security then 9/10 times you are looking at Framework Limitations in all reference documentation.

My recommendation:

First build your solution in Anvil.Works, then export the Anvil App to your GitHub and get the .py and .yaml files.
Secondly, rebuild the app by editing/importing the Anvil code, line for line, into a Django App @ https://www.djangoproject.com/
And then Finally; Test and deploy your Django app for production with a port to https://www.lino-framework.org/ so that you’ll be able to handle all the data responsibly.

Hope that helps!

Sorry, but I don’t agree.

Perhaps you know django and you can manage a web server and you are a database administrator and you have time to waste going through all the hoops required to create a secure app.

I have done some of that in the past, and I know enough to know that I don’t know enough. My old apps look great, but I’m sure they are not safe. I don’t know enough and I’m not interested in going back wasting time learning all those things only to end up with huge security holes that I can’t see because I don’t know enough.

Your points make sense if you have a large team building a large app. Most of us Anvillistas work solo or in very small teams, and enjoy delegating all security concerns to the Anvil team.

The few times I saw security holes when comparing Anvil apps to django apps the holes were on the django side. Perhaps you can get a HIPAA certified app with django and you can’t with Anvil, but if you get your advice about security from this forum, then please stay away from HIPAA apps!

Apologies for the painful reminders, and thank you for the elaboration. I also know that I don’t know. And like you, I also had to become all those things, even to the extent of Professional Identity Crises, in that everything becomes your job out of necessity, and no matter how diverse and synergistic and dedicated our teams are, we still cannot pin down exactly what our ‘‘Job Titles’’ are supposed to be…

Enter the Full Stack Hybrid Compiler

That’s what you end up becoming when you refuse to write more than a 100 lines of code per problem. What I love most about Anvil.Works? It works, and you just gave a brilliant explanation as to why, and it objectively shows that you need someone to be all those things, even on very small projects, in order to achieve anything remotely similar as to what Anvil.Works offers.

Regarding your use-case for HIPAA compliant apps, I just pulled the list of PHI classes (https://archer-soft.com/en/blog/4-steps-make-your-app-hipaa-compliant), see the last paragraph for my proposed Anvil Specific Handling Solutions (no demo);

  1.   Names of patients
    
  2.   All geographical subdivisions smaller than a state
    
  3.   Dates directly related to an individual, including birth date, admission date, discharge date, date of death
    
  4.   Phone numbers
    
  5.   Fax numbers
    
  6.   Emails
    
  7.   Social Security numbers
    
  8.   Medical record numbers
    
  9.   Health plan beneficiary numbers
    
  10. Account numbers

  11. Certificate/license numbers

  12. Vehicle identifiers and serial numbers, including license plate numbers

  13. Device identifiers and serial numbers

  14. Web URLs

  15. IP addresses

  16. Biometric identifiers, including finger and voice prints

  17. Full face photographic images and any comparable images

  18. Any other unique identifying number, characteristic, or code.

So basically to be HIPAA compliant, all the above information must be dynamically adjusted and secured during collection, transport, storage and retrieval. The majority of the data types must also be collected by the App, as a missing data type ex. fingerprints, might lower our chances of approval. This data must be practically, publicly view-able, without disclosing any personal information about the patient, or exposing the data to any non-secured routes or spaces.

With Anvil.Works this is easy!

First go to Anvil Docs | Encrypting Secret Data and follow the instructions to create a secure key, then use that key to encrypt/decrypt all user data whenever it is handled, i.e called or collected, like so;

def encrypt_value(plaintext): return anvil.secrets.encrypt_with_key('encryption_key', plaintext)

def decrypt_value(ciphertext):
return anvil.secrets.decrypt_with_key(‘encryption_key’,
ciphertext)

Storing the Data:

SQL, php and postgreSQL etc are notoriously easy to set up incorrectly, and to break into by accident. So we’re going to want to upload all data securely, via Uplink, to an external Database using WebSockets:

First go see Anvil Docs | Uplink Security, where there is an explanation of the difference between Client Side Uplink and Server Side Uplink tokens. In this case, depending on your internal App layout and functionality, you would extensively use Client Side Uplink Tokens in your code to ensure minimum privileges are afforded to the relevant code blocks. If there is a Token involved in an Anvil call, you can rest assured the data is using the wss: protocol with bi-directional 256 SHA encryption (unless I’m mistaken).

The main thing is Internal Data Processing, which is done by your Code, which we will look at next:

See API reference at Anvil Docs | segment.client which shows you how to Track, Group and most importantly, alias Users. You will also have to write code to create reference, anonymous, users internally to be aliased against your real users. You can do a simple API call to randomuser.me as a Background Task, see Anvil Docs | Background Tasks, and then do the User Alias and Secure Export, as according to the docs; Anvil Docs | Calling functions remotely

You’re going to want to setup a secure Database, I’d reccomend CouchDB or Redis to start out with, Mongo for long term. Then you can Post and Get data from the database using HTTP requests, the Uplink, or you can siphon off data dynamically over time, by creating secure HTTP endpoints that only exposed the alias User Data. (If you have the same process for creating User Aliases running on both the server and the database, you may be tempted to use it in itself as a primitive encryption algorithm, since the order in which the Data is processed determines the obfuscation specifics. Don’t do it. Guessing hidden patterns is what most coders do best.

Well I hope my super verbose answer gets you going in the right direction, pardon if it is hard to follow or off topic, welcome to suggest edits.

I don’t need to go in any direction…
What is the point of your post?
The original post was a question about managing Excel documents and it already has an answer, I don’t understand if you are trying to add to that or are asking a question.

(In the middle of the thread there is a digression about the size of the editor, which has been addressed and is now part of the standard ide.)

1 Like