Why Python Beats HTML+JS for Web Development
Web development is pretty unwieldy. You need to master JS and HTML and CSS and Python (or Rails or Node) and a ton of frameworks.
Here are 12 reasons why building your front-end and back-end in Python is so great:
1. Your UI components are all Python objects.
Running Python in the browser means you can modify your UI components in Python. Drag and drop them onto the page to build the user interface, then set their properties and call events on them from Python code.
2. Call server-side functions from the browser
In traditional web-dev, calling from the browser to the web server is a pain. You have to set up a URL route, smush all your data into JSON, set up the AJAX request, asynchronously get a response…so much work!
With Anvil, you just call a function. Add a decorator to any function, then just call the function from browser code. Pass Python objects as arguments; return Python objects. Job done.
3. The database is built-in
Setting up and maintaining a database is a drag. So Anvil has a built-in database. Design your data tables graphically, then query or update rows with Python. (Can you return a lazy paginated query response to the browser, as a Python object? Of course you can! That would be dozens of lines of code in most web frameworks.)
4. Connect your code running anywhere
Anvil is “serverless” - your code is automatically hosted in the cloud. But what if you want to run code on your computer? Just use the Uplink!
5. Binary data is easier to handle
“Uploading a file” is basic functionality. So it must be simple in every web framework. Right? Surprise! Handling binary data – like files, images, or PDFs – is remarkably difficult in a traditional JS app. (If you’re feeling mean, try saying ‘
enctype="multipart/form-data"’ to a seasoned web developer. Watch them shiver.)
But Anvil makes it easy. All binary data (pictures, uploaded files, etc.) is represented as a Python object! You can pass binary data as an argument to a server function. You can store it in a Data Table. You can use it with Anvil components. For example, rendering and downloading a PDF is literally this simple:
# In a server module: @anvil.server.callable def get_pdf(): return anvil.pdf.render_form('Form1')
# In the browser: pdf = anvil.server.call('get_pdf') download(pdf)
6. User authentication comes built-in
Building user authentication is tedious, but deadly if you get it wrong! Half of the OWASP vulnerabilities are “ways you can get authentication wrong”.
Anvil’s built in User Service handles signup, login, and user permissions for you, out of the box. It takes one line of Python code to present your users with a signup form with email validation – just call
7. Email support is built-in too
Send an email with one line of code. Receive emails with one line of code! It’s all built in with Anvil’s Email service.
8. PDF generation is also built-in
Did someone say “batteries included”? Create PDF documents with our drag-n-drop editor, then render and download them with a Python call.
Tutorial: How to Create a PDF on the Web
9. Use your favorite Python packages
10. You can still build HTTP APIs
Or just watch Bridget build and deploy a JSON API in 20 seconds:
11. One-click integrations
Your Anvil app can easily connect to services from Google, Microsoft, Facebook, Stripe and more. Log your users in using Google, Microsoft and Facebook Single Sign-Ons, take payments with Stripe, or display interactive Google Maps.
12. Easy encrypted storage
You don’t want to leave passwords lying around in your source code. The App Secrets service provides easy-to-use encrypted storage of sensitive data, like passwords or encryption keys.
Get Simple. Keep the Power.
Anvil gives you all the power of Python, and none of the complexity of traditional web frameworks. If you’re a Python developer, you can build full-stack web apps without needing anything else.
Don’t get locked in.
Anvil’s runtime is open source, so you can take your app and deploy it anywhere. You don’t even need our editor to create an Anvil app!
Get Started with Anvil
Nothing but Python required!
Deploy data science to the web with Deepnote
Generate PDF Invoices with Python
Python vs the Pandemic
2020 has been a difficult year for people all around the world.
We’ve seen an incredible response from the Anvil community, with a number of our users building tools and applications to help deal with the effects of the COVID-19 pandemic. We’ll take a look at some of the tools being built with Anvil to help people impacted by the virus.