Python and HTML
September 19, 2019 2:21 PM   Subscribe

Explain to me like I'm five how to put a nice HTML user interface on top of my Python code, how to bring together the parts.

I have modest skills in building pretty (albeit essentially static) websites. I have just sufficient skills in Python to make a program that does what I want it to do. How do I put the two together to have something other people can use in a browser? I have googled of course and am completely bewildered by all the things. Possible responses include "O sweet summer child don't you know people go to school for this" and "well, actually, why don't you do this other thing", but those responses are not really what I am hoping for.

Here's what I hope you will tell me:
Python + ??? + HTML/CSS/js = app that runs in a browser.
Solve for ???
posted by pH Indicating Socks to Computers & Internet (7 answers total) 12 users marked this as a favorite
I think you might get a lot of mileage out of using a Python web framework, which will take care of a lot of the work of connecting parts A to B so you can focus on making a thing go. Django is the one with the most built in batteries and I think you could get a long way going through their tutorials. Flask is a more lightweight one in case you find that more your speed.
posted by foxfirefey at 2:31 PM on September 19, 2019 [2 favorites]

Last time I tried to do this (convert a CLI python program to web) I used Flask, since it's easy to change just what's needed in your script to make it output something Flask can use.

I wouldn't use Django since it'd add a lot of complexity that you probably don't need.
posted by Memo at 2:36 PM on September 19, 2019 [1 favorite]

Flask is a simple, relatively low-friction way to get started. And there's an excellent tutorial with videos that will walk you through setting up and refining a simple web application. The tutorial gets progressively more complicated, but you can stop as soon as you get what you need.
posted by dws at 2:46 PM on September 19, 2019 [1 favorite]

Lovely, thank you all! Flask it is! If anyone has any more info for me, I am all ears!
posted by pH Indicating Socks at 3:43 PM on September 19, 2019

There's another option that I initially forgot about--and that's making a Lambda on AWS. You can write them in Python, and they have a guide on how to make a website using them.
posted by foxfirefey at 3:54 PM on September 19, 2019

Flask is the general solution for sure. Django if you need a database layer.

On the off chance that you what you want to do it serve a bunch of graphs, I've been in love with Plotly Dash recently.
posted by supercres at 7:35 PM on September 19, 2019 [1 favorite]

Flask is a good suggestion, but deployment can take a little knowhow. For easier hosting, you might take a look at PythonAnywhere, Glitch, or Heroku.
posted by john hadron collider at 6:41 AM on September 20, 2019

« Older Try this sinus triumph   |   Should we end this marriage? Newer »

You are not logged in, either login or create an account to post comments