Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DarthRoblox
Nov 25, 2007
*rolls ankle* *gains 15lbs* *apologizes to TFLC* *rolls ankle*...
Quick question about error handling - I'm doing some DB interaction using pandas methods that's reliant on boto for some AWS credentials handling.
When I get an error, pandas always seems to return a pandas.io.sql.DatabaseError, no matter what the specific problem is.
If I gently caress up my actual SQL I get this response:
code:
pandas.io.sql.DatabaseError("Execution failed on sql: <bad sql> An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: Queries of this type are not supported\nunable to rollback")
or if there's an issue with the credentials I get the same error type with a different message:
code:
pandas.io.sql.DatabaseError("Execution failed on sql: <OK sql> Unable to locate credentials\nunable to rollback")
I'd like to handle those errors differently, but since I get the same type of error I'm not sure what the best way to go about that is. The two options I've come up with are:

1. Parse the error message as a string and look for key phrases - ie "Unable to locate Credentials" or "Queries of this type are not supported". This feels gross, would break if an update changed the error messages, might not handle all error types.

2. Use the __context__ field to examine the chain of exceptions and look for something more specific - something like:
code:
def _get_error_context(error):
    error_context = list()
    while error is not None:
        error_context.extend([error])
        error = error.__context__
    return error_context

def _check_exception_in_context(exception, error_context):
    return max([isinstance(error, exception) for error in error_context])
Which gives me:
code:
[pandas.io.sql.DatabaseError("Execution failed on sql: Unable to locate credentials\nunable to rollback"),
 pyathena.error.NotSupportedError(),
 pyathena.error.DatabaseError('Unable to locate credentials'),
 botocore.exceptions.NoCredentialsError('Unable to locate credentials')]
I like that solution a bit better, but it feels like there should be a better way to do this that I might not know about - I haven't able to find anything useful via googling though.

Is there a better way to go about this?

Adbot
ADBOT LOVES YOU

MISAKA
Dec 10, 2018
If they dont provide more specific error types you are pretty much screwed. Both the error messages, and the nested errors may change under you. Imo, the error messages look more stable, cause noone ever changes them (case in point - enotty)

Hadlock
Nov 9, 2004

Thermopyle posted:

I'd go with Docker.

A quick google shows a bunch of tutorial-lookin' results for "docker flask mysql".

All our python code runs in containers at this point, especially the flask stuff.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

DarthRoblox posted:


Is there a better way to go about this?

Good libraries provide SomeLibraryException.code set to some constant like SomeLibraryException.NO_RESPONSE that you can check. Then you have the 99% of libraries that don't do this :(.

NinpoEspiritoSanto
Oct 22, 2013




Thermopyle posted:

I'd go with Docker.

A quick google shows a bunch of tutorial-lookin' results for "docker flask mysql".

Why? They're already planning to deploy to a VM. A single docker image makes no sense on a VM (unless someone wants to educate me?)

I realise docker images aren't solely intended for baremetal deployment, but a single app deployed to a VM doesn't sound like something that needs another layer of virtual encapsulation to get the job done, other than it's a Cool Tool.

Depending on knowhow you can range from just sftp-ing code to the VM, to things like gitolite that mean you can push to a remote git that'll check out the code you push to a "live" location, to uploading a tarball to creating an ansible script that does it all for you. Ultimately, the question is "how do I get files from location A to location B and have them accessible from location B". This comes down to your own skills and what you're comfortable with. There's no point chatting about docker or various deployment tools if they just go over the head of the person trying to get something live as a learning experience.

Personally, Grump, I'd be asking what your ultimate goal and your current knowledge is. You say you're just a clueless front end person, but you've put a flask app together so not that clueless, where does your comfort zone live? How are you with Linux? SFTP? SSH? Nginx/Apache? etc.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Bundy posted:

Why? They're already planning to deploy to a VM. A single docker image makes no sense on a VM (unless someone wants to educate me?)

I realise docker images aren't solely intended for baremetal deployment, but a single app deployed to a VM doesn't sound like something that needs another layer of virtual encapsulation to get the job done, other than it's a Cool Tool.

Depending on knowhow you can range from just sftp-ing code to the VM, to things like gitolite that mean you can push to a remote git that'll check out the code you push to a "live" location, to uploading a tarball to creating an ansible script that does it all for you. Ultimately, the question is "how do I get files from location A to location B and have them accessible from location B". This comes down to your own skills and what you're comfortable with. There's no point chatting about docker or various deployment tools if they just go over the head of the person trying to get something live as a learning experience.

Personally, Grump, I'd be asking what your ultimate goal and your current knowledge is. You say you're just a clueless front end person, but you've put a flask app together so not that clueless, where does your comfort zone live? How are you with Linux? SFTP? SSH? Nginx/Apache? etc.

Identical environment on dev and production and Docker is the easiest way to that end goal.


Whether you're deploying to a VM or not is a red herring.

Thermopyle fucked around with this message at 02:58 on Jan 11, 2019

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

Bundy posted:

Personally, Grump, I'd be asking what your ultimate goal and your current knowledge is. You say you're just a clueless front end person, but you've put a flask app together so not that clueless, where does your comfort zone live? How are you with Linux? SFTP? SSH? Nginx/Apache? etc.

I'm pretty comfortable with Linux and Apache, but that's basically the extend of my knowledge. I've deployed personal sites and React apps on Apache without too much trouble. I have no issue securing servers and getting something on the web, in a nutshell.

This is really just a pet project, so I'm all for learning new tech. I didn't know any Flask / Python before this. Docker is still a mystery to me, and I've watched quite a bit of tutorials - none of that knowledge ever sticks with me. If I'm going to learn Docker, I need a tutorial that's going to spell everything out for me very clearly - I have yet to find any good ones and I even have a Pluralsight subscription

teen phone cutie fucked around with this message at 04:18 on Jan 11, 2019

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Docker is much easier than you think...once the concept behind it *clicks* in your brain. Just devote a morning to really messing around with Docker and going through multiple tutorials. The payoff once it clicks for you is worth it in the end for a lot of reasons.

One way of thinking about Docker that might help it click for a developer: Think of containers like objects/classes but they encapsulate a whole application and everything needed for it to run instead of encapsulating data and code. And, just like with objects, you don't have to think about the nitty-gritty of how it works internally, just the functionality that the container/object exposes...aka which network ports and possibly where it writes data to.

So, with a Flask application, it's very possible that the only public "API" is port 5000. The container hides away the operating system, python, everything. Then you might have the same thing for MySQL, and the two containers talk to each other. Nginx will reverse proxy requests coming in to (say) port 80 on the host machine to port 5000 which Docker has grabbed hold of for your Flask application, and while processing the request, Flask accesses MySQL on whatever port you set up when running the container.

The big and important benefit of this is that it's super simple to run absolutely identical containers on your work computer and where the heck ever else you want to.

There's no messing with trying to run multiple python versions or installing MySQL in multiple versions. If you can install Docker, you can run your containers, which have encapsulated the version of Python and the version of MySQL you're developing against.

Hadlock
Nov 9, 2004

It's super simple yeah. Install docker, make sure you have all your requirements in a requirements.txt and go find probably the official python 3.7 docker file and then do a docker build . -t hadlock/myapp: latest

Then do a docker run -itd -p 5000:5000 --name=myapp hadlock/myapp:latest and then go browse to 0.0.0.0:5000 ... You can tail the logs via docker logs -f myapp

Probably messed up some of the syntax due to being on a phone but that's really it. Then you can push the container to a remote registry and you can pull it down, libraries and all already correctly preconfigured along with the correct version of python etc etc... run that exact same thing anywhere inside your firewall, works exactly like it did on your dev laptop. No custom bullshit ansible that's slightly different than the ansible your co-worker wrote to deploy that other python app.

Side load in config like, -v /localpath/to/application.yaml:/containerapp/application.yaml

And then just jump into the app container like, docker exec -it myapp bash

Hadlock fucked around with this message at 05:03 on Jan 11, 2019

SnatchRabbit
Feb 23, 2006

by sebmojo

baka kaba posted:

dict1.update(dict2) basically adds all the key/value pairs from dict2 into dict1. So it'll overwrite any keys that already exist

Every stack you're adding has a "Stackname" key and a "Tags" one, so those values will just get overwritten each time. Sure you don't want a list of stack dicts? Or maybe a dictionary where each key is the name of a stack, and that maps to the actual stack dict, or something like that

I ended up just having a list inside a dict. Noticed right after I posted. Thanks!

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Thanks for the help guys. I think I'm going to look into some Docker tutorials and report back.

On the same note, I'm having some issues with how I'm getting my data back from one of my endpoints, specifically with Marshmallow and SQLAlchemy

https://gist.github.com/martinmckenna/eb5eeee5869663fc8f2e52a5e7ef72c9

I have a many-to-many relationship between cocktails and ingredients, but I also have more data than just foreign keys on the relational table, ings_in_cocktail, such as "ounces." When I GET /cocktails/, it returns something like this:

code:
{
  "cocktails": [
    {
      "glass": "rocks",
      "ingredients": [
        {
          "ingredient": {
            "ing_type": "liquor",
            "id": 1,
            "name": "gin"
          },
          "ounces": 20
        }
      ],
      "finish": "stirred",
      "id": 1,
      "name": "gin and tonic"
    }
  ]
}
What I'd like to do is combine the spread the "ounces" property with the "ingredient" dict.

I want the data to look like the following:

code:
{
  "cocktails": [
    {
      "glass": "rocks",
      "ingredients": [
        {
          "ing_type": "liquor",
          "id": 1,
          "name": "gin",
          "ounces": 20
        }
      ],
      "finish": "stirred",
      "id": 1,
      "name": "gin and tonic"
    }
  ]
}
After searching the web for hours, I can't find a way to do this easily with Marshamallow. Is there some easy way I'm missing?

teen phone cutie fucked around with this message at 02:52 on Jan 14, 2019

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
My wife is trying to pick up programming, and I thought Python was a good language to start with because of its whitespace rules and I'm assuming a lot of immutability.

Does anyone have a good course or book recommendation to start with? I've been a dev for 7 years now so I can help fill in the blanks a bit, but I don't work with Python at all so something comprehensive and easy to understand would be best.

Also what's being used for Python web projects? Is it Flask?

punished milkman
Dec 5, 2018

would have won

Modest Mouse cover band posted:


Also what's being used for Python web projects? Is it Flask?

I've seen this conversation a million times now, and if you're interested in doing web dev stuff with Python you should be learning Django.

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost

punished milkman posted:

I've seen this conversation a million times now, and if you're interested in doing web dev stuff with Python you should be learning Django.

yah, i do flask all day every day but thats cuz i know wtf im doing

flask is simpler but it gives you lots less poo poo

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

punished milkman posted:

I've seen this conversation a million times now, and if you're interested in doing web dev stuff with Python you should be learning Django.

Awesome, thank you I knew there was another one. I found this and she already likes it better than CodeAcademy: https://tutorial.djangogirls.org/en/ plus she has a chromebook so it saves VM setup time for the moment.

NinpoEspiritoSanto
Oct 22, 2013




Django or Pyramid are probably the frameworks to pick up for things that are somewhat sane.

https://greenteapress.com/wp/think-python-2e/

Think Python is great for beginners.

NtotheTC
Dec 31, 2007


For Django specifically, once youve done the tutorials (of which there are many excellent ones suxh as the one youve already found) the Two Scoops of Django book makes an excellent reference book. Its expensive in hardcopy form but I think you can get an electronic copy cheaper

priznat
Jul 7, 2009

Let's get drunk and kiss each other all night.
Anyone know of a good project that can webscrape for pricing information? I was thinking beautifulsoup mostly. Just have a few pages from vendors I setup watches on (like camelcamelcamel but cross vendor)

I’m sure this has probably been done already a million times so if I could just sponge off one and check out the code that’d be super.

NinpoEspiritoSanto
Oct 22, 2013




priznat posted:

Anyone know of a good project that can webscrape for pricing information? I was thinking beautifulsoup mostly. Just have a few pages from vendors I setup watches on (like camelcamelcamel but cross vendor)

I’m sure this has probably been done already a million times so if I could just sponge off one and check out the code that’d be super.

There's also scrapy iirc. Automate the boring stuff has some good stuff on web scraping.

Dr Subterfuge
Aug 31, 2005

TIME TO ROC N' ROLL

Modest Mouse cover band posted:

My wife is trying to pick up programming, and I thought Python was a good language to start with because of its whitespace rules and I'm assuming a lot of immutability.

I guess I don't exactly know what you mean by this, but when I think of python I don't think "immutability."

NinpoEspiritoSanto
Oct 22, 2013




So I've been playing with/now seriously considering contributing to a newish Python library called Trio

It's a truly excellent approach to async programming in Python, based off ideas from Curio, Dave Beazley's hobby async project that began life when he did a talk on asyncio at Pycon Brasil after Python added async/await syntax to the core.

I've rehosted the asyncio: A dumpster fire of bad design rant as the original site has been down for some time (I've let the original author know, author information is still in the left untampered html). This gives a decent, angry rundown of what's wrong with asyncio (mostly still today).

Trio's author and now Python core developer Nathaniel J Smith has some great blog posts on different approaches to async now that async/await were added to the language (predates Trio, uses Curio as examples), as well as some very good post-Trio reasoning about just what's wrong with the traditional approach to async programming in Python here. Edit: There's also Andre Caron's take on NJ Smith's reasoning about asyncio.

Last night I had a use case for checking this out and after about a half hour I'd knocked together a script to check a blacklist, then validate, check MX record and attempt to see if the mailbox exists for 10k email addresses to help filter out spam/invalid vs legit emails on a subscriber list for a friend of mine, total runtime was 3 minutes and change.

I highly recommend having a read and a play, even if it's not mature enough for anything you're working on yet (it does lack some native libraries, but does provide a bridge for asyncio focused libs). Or hell if you're bored, join the project/contribute!

If you prefer to watch presentations on such things, NJSmith did a decent talk at Pyninsula, with the interesting bits being how you can implement the Happy Eyeballs algorithm in Trio vs Twisted and asyncio:

https://www.youtube.com/watch?v=i-R704I8ySE

NinpoEspiritoSanto fucked around with this message at 13:59 on Jan 18, 2019

CarForumPoster
Jun 26, 2013

⚡POWER⚡

priznat posted:

Anyone know of a good project that can webscrape for pricing information? I was thinking beautifulsoup mostly. Just have a few pages from vendors I setup watches on (like camelcamelcamel but cross vendor)

I’m sure this has probably been done already a million times so if I could just sponge off one and check out the code that’d be super.

ParseHub is a non programming (its firefoxes element picker for scraping best I can tell) solution that I found pretty easy to use after a few minutes of their tutorial videos. Has some limitations but if you want very quick and dirty, I like it and its free for up to 200 pages at once. You can load like search terms or whatever straight from a csv or json and loop over them which is nice.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

trio>asyncio

but then you have another dependency, which isn't worth it for some

NinpoEspiritoSanto
Oct 22, 2013




Thermopyle posted:

trio>asyncio

but then you have another dependency, which isn't worth it for some

Eh, maybe but most apps or devs worth their salt don't just rely on stdlib, considering the horror that is datetime, urllib, etc. Trio will end up to async as requests is to urllib, attrs to classes and pendulum to datetime, IMHO.

Stdlib has some nice things, but is hampered in some ways when it comes to libraries as you're stuck on that release cycle. I'd take an extra line in requirements.txt over wrestling with asyncio, it's still somewhat painful even with the new syntax.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Bundy posted:

Eh, maybe but most apps or devs worth their salt don't just rely on stdlib, considering the horror that is datetime, urllib, etc. Trio will end up to async as requests is to urllib, attrs to classes and pendulum to datetime, IMHO.

Stdlib has some nice things, but is hampered in some ways when it comes to libraries as you're stuck on that release cycle. I'd take an extra line in requirements.txt over wrestling with asyncio, it's still somewhat painful even with the new syntax.

Right, but there's a difference between not just relying on stdlib and adding an extra dependency. There's costs beyond the few extra bytes in requirements.txt to every dependency. Some dependencies are worth it for some projects and not for other projects.

I'll quote myself here talking specifically about django packages, but the same holds in general...

me posted:

When and how to use other libraries is a hard question to answer.

Of course, the at-first-blush answer is "yes, use them! Why re-invent the wheel?"

However, there are costs to using a library, and sometimes those costs are more than the costs of writing the functionality yourself.

Some questions to ask about using another library:

  1. How confident are you that the library is secure and will continue to be?

  2. Will it be updated with new features, security patches, and any other updates it might need?

  3. Does the abstraction the library offers mesh well with the abstraction you need? Using a library usually means altering your requirements or how you think about the problem being solved.

  4. How much code, thought, labor, maintenance is the library saving you? Many libraries are very small wrappers around very little functionality.

  5. Is the scope of the library much larger than the functionality you actually need? Many times you need just a bit of functionality, but the library brings in a bajillion lines of code and configuration, and potential security vulnerabilities.

  6. Do the core devs seem responsive? Are they answering issues on the issue tracker? Are pull requests being accepted?

  7. Do you have the know-how to implement the functionality yourself or can you gain the know-how in an amount of time reasonable to you? I use high-level machine learning libraries all the time because I'm a dummy and don't currently have the time to gain a deeper understanding of the subject matter.
I use django packages (and libraries in general) constantly. I also write much functionality that I could use a library for.

For example, I don't use stuff like django-allauth and other third-party social auth type of libraries. With some of them you can peruse the issue trackers and find problems that have gone many months or years without any progress, they include functionality for tons of different providers, they have convoluted configuration. It's just easier to write the functionality for myself.


You can have a large application where very little of the logic has anything to do with async (in fact, I wouldn't be surprised if this holds true for most non-trivial applications). There's no point in tying yourself to a third party no matter how much easier they make async when you've got 10 lines of code devoted to it.

Like I said, trio is definitely better than asyncio, which is why I've contributed a lot bug-fixing and features.

However, people can be too eager to try the hot new library without considering the consequences...which is part of the reason you end up with the leftPad fiasco in Node-land.

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
What is the practical difference between attrs.attrib(init=False) and attrs.attrib(default=None)?

NinpoEspiritoSanto
Oct 22, 2013




Boris Galerkin posted:

What is the practical difference between attrs.attrib(init=False) and attrs.attrib(default=None)?

One effects how __init__() is handled when initialising the class:

https://www.attrs.org/en/stable/init.html

The other is for specific value defaults:

https://www.attrs.org/en/stable/init.html#defaults

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

Thermopyle posted:

Docker is much easier than you think...once the concept behind it *clicks* in your brain

So I dockerized my Flask app and have everything working locally no problem.

Now how do I get this thing on a Linux box? I can't find one tutorial online about this. I'm at the point where running docker-compose will build my MySQL and app containers, but I have no idea what is required to get me a working app on a server

teen phone cutie fucked around with this message at 09:20 on Jan 20, 2019

cinci zoo sniper
Mar 15, 2013




Well, what exactly are you having trouble with :v:? Install Docker & Friends on your server, and run docker compose there. Sprinkle your compose.yml with `restart: always` so it can unshit itself if something happens and you are more or less good to go (well, that and obviously mount your app data in the external (server) fs).

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

cinci zoo sniper posted:

Well, what exactly are you having trouble with :v:? Install Docker & Friends on your server, and run docker compose there. Sprinkle your compose.yml with `restart: always` so it can unshit itself if something happens and you are more or less good to go (well, that and obviously mount your app data in the external (server) fs).

Like.....just run git clone my-project in the root directory on the server and then run docker-compose?

And curling the IP will just work?

quote:

(well, that and obviously mount your app data in the external (server) fs).

uhhhhhh what?

teen phone cutie fucked around with this message at 09:28 on Jan 20, 2019

cinci zoo sniper
Mar 15, 2013




I see. Read

1) https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-centos-7
2) https://www.digitalocean.com/community/tutorials/how-to-work-with-docker-data-volumes-on-ubuntu-14-04

for the Docker stuff then. But yeah you git clone your project into your server (I would not do it in "server root" (home directory), rather I prefer doing things like these in /opt/ but that's a matter of preference to a large extent), then `docker-compose up -d`. Assuming you configured restart behaviour and volumes correctly in compose.yml, the app will persist through docker and server (provided that you made Docker a service) restarts, or crashes if those happen (obviously depends on how hard and how much crashed). Without restart configuration it will stay dead, without volumes you will lose all data accumulated by app(s) - while that is far from always necessary, you mention MySQL container so you probably don't want that database to lose all data in it if anything happens.

About curling, can you elaborate more?

Also, figure out what firewall your server has and look up some configuration guide(s) on DigitalOcean, they have pretty good basic reference material for most things.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

cinci zoo sniper posted:

I see. Read

1) https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-centos-7
2) https://www.digitalocean.com/community/tutorials/how-to-work-with-docker-data-volumes-on-ubuntu-14-04

for the Docker stuff then. But yeah you git clone your project into your server (I would not do it in "server root" (home directory), rather I prefer doing things like these in /opt/ but that's a matter of preference to a large extent), then `docker-compose up -d`. Assuming you configured restart behaviour and volumes correctly in compose.yml, the app will persist through docker and server (provided that you made Docker a service) restarts, or crashes if those happen (obviously depends on how hard and how much crashed). Without restart configuration it will stay dead, without volumes you will lose all data accumulated by app(s) - while that is far from always necessary, you mention MySQL container so you probably don't want that database to lose all data in it if anything happens.

About curling, can you elaborate more?

Also, figure out what firewall your server has and look up some configuration guide(s) on DigitalOcean, they have pretty good basic reference material for most things.

wait holy poo poo...I just spun up a server really quick and followed these steps.

It just works. Navigating to http://ip-address-here:5000 just works.....That's crazy it's like magic

cinci zoo sniper
Mar 15, 2013




Yep, that's the selling point of Docker and container tech in general. The solutions are portable, and if it works somewhere, it works [almost] anywhere.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
One more question, which is probably better suited for another thread - what's the easiest way to get an SSL for a docker Flask app?

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Make sure you read some stuff on securing your new server as well. Nobody is going to specifically target you, but they will throw out wide nets and see who they can get. Last thing you want is someone using your server in their bitcoin mining operation.

https://www.digitalocean.com/community/tutorials/7-security-measures-to-protect-your-servers

E: the most important thing there is to use ssh key authentication, disable password logins, and especially disable root logins. Everything else is secondary.

Boris Galerkin fucked around with this message at 10:38 on Jan 20, 2019

NinpoEspiritoSanto
Oct 22, 2013




Grump posted:

One more question, which is probably better suited for another thread - what's the easiest way to get an SSL for a docker Flask app?

letsencrypt provide free certs that you can renew automatically every 3 months

cinci zoo sniper
Mar 15, 2013




Grump posted:

One more question, which is probably better suited for another thread - what's the easiest way to get an SSL for a docker Flask app?

A few ways would be setting nginx up in front of Docker or just adding appropriate SSL context for your Flask app (e.g. like so).

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

cinci zoo sniper posted:

A few ways would be setting nginx up in front of Docker or just adding appropriate SSL context for your Flask app (e.g. like so).

I'd probably want to set up nginx in front of it if I want to be able to visit domain.com without having to do the additional :5000 at the end right?

NinpoEspiritoSanto
Oct 22, 2013




You should use something other than the built in http server to talk to the world at large, yes.

I'm on my phone, but search for Chris Warrick nginx uwsgi. He has a great guide for deploying python apps along with nginx. Even has an ansible book if that's your thing.

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




Grump posted:

I'd probably want to set up nginx in front of it if I want to be able to visit domain.com without having to do the additional :5000 at the end right?

Not necessarily, but I would roll with Nginx setup regardless, it's industry standard for this use case. Initial setup can be a bit of a hurdle, but once you are past that it's smooth sailing and will open a lot of options for you.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply