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.

We love Python because of its motto: Simple is better than complex. So what would web development look like, if it were 100% Python – even the front end? We built it, and it’s called Anvil.

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.

Building the UI for a feedback form. Check out the tutorial.

Building the UI for a feedback form. Check out the tutorial.


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.)

A Data Table in Anvil

A Data Table in Anvil


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!

Got a Jupyter notebook? Call it from the web!
Got a local database? Write a local script to query it, then call it from the web!


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 anvil.users.login_with_form().

As well as email login, Anvil supports Google, Microsoft, Facebook, and SAML SSO. (What about two-factor authentication? Of course it works.)


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.

Building an app to receive email is so simple, we did it in a 4-minute video:


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

One of the best features of Python is the numerous packages available. With the Full Python runtime, you have access to a very long list of your favorite Python libraries to build your web apps.


10. You can still build HTTP APIs

Want to build an HTTP API, so non-Anvil apps can interface with your service? Creating HTTP endpoints is nearly as simple as making functions you can call from the browser. Check out this tutorial.

Or just watch Bridget build and deploy a JSON API in 20 seconds:

Creating and deploying a working JSON API in 20 seconds.

Creating and deploying a working 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.

Learn to store encrypted data with another 4-minute tutorial


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.

And if you do want to tweak something with HTML, CSS or JavaScript, there’s always an escape hatch! Use a Javascript library from Python code, or style your app with HTML CSS.

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!


Start Building

Anvil is free is to use, so you can start building right away! Start with a tutorial to get acquainted with Anvil or check out the documentation to learn about some of Anvil’s other features.

Learn More