Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Roger Ying
    @rogerying
    Thanks guys! Heads all mixed up because I used ansible for ‘python for entrepreneurs’, and then doing the crash course in docker, nginx, heroku... trying to mix everything together (there’s some overlap but not all, eg lets_encrypt is needed for docker?)... so just a bit confused and heads all over the place
    And have a lot of free credits on Aws, so trying to figure out how to get elastic beanstalk working with docker etc....
    Chris May
    @_ChrisMay_twitter
    @rogerying It's easy to do. You can go very deep very quickly with web development.
    Roger Ying
    @rogerying
    And I’ve run into weird issues with ansible on the test server with 500 internal server error, and https not renewing or something
    Chris May
    @_ChrisMay_twitter
    That's I think one of the hard things... constraining yourself to learn or explore only one or two new topic at a time.
    When you're developing, it's much easier to not worry about https.
    Roger Ying
    @rogerying
    Ok, got it.. thanks
    Right now I’m trying to figure out how to port the ansible code to docker lol
    Roger Ying
    @rogerying
    And trying to get uWSGI working in nginx on the docker container
    Michael Kennedy
    @mkennedy_twitter
    Hi @rogerying Check out the deployment chapter in the course you got. Near the end… It has all this laid out exactly. uWSGI + nginx on Ubuntu.
    Roger Ying
    @rogerying
    @michael, went through that chapter and docker. I’m trying to deploy a docker container to amazon ecs... I’m finding it much more challenging than expected... still trying to get it done.. is there an easy way to launch a docker container onto aws? I have a lot of free credits on aws
    Michael Kennedy
    @mkennedy_twitter
    @rogerying AWS has super locked down linux machines. Try it on a local VM or install the local docker tools for windows or macOS and do it there first. That should help iron out what is giving you trouble at AWS. BTW, you are better off going with DigitalOcean or Linode. They also have credits but they charge about 12x (not percent, times!) less than EC2 for the same machine. Over time, that’d be worth it. You can use these links to get the credits there if you want….
    Digital ocean: http://do.co/python
    Chris May
    @_ChrisMay_twitter
    Would you say that DigitalOcean is a better choice over Linode for people who have little to no experience with unix?
    I haven't used DO in the past, and I currently use Linode and love it. Just my impression
    Michael Kennedy
    @mkennedy_twitter
    Hi @_ChrisMay_twitter I feel like they are both so super close to simple just get into VMs and go that there really isn’t much of a difference. They each offer other features and maybe those matter to someone but I doubt it matters a lot. But EC2 is complex and pricy. What you get for $5 at either will cost you about $157 at AWS (bandwidth + compute price).
    Chris May
    @_ChrisMay_twitter
    Cool! Good to know. Thanks!
    And thanks for the referral code! I haven't paid for my Linode yet, and it's been a few months. :D
    Michael Kennedy
    @mkennedy_twitter
    :) lovely!
    Roger Ying
    @rogerying
    @Michael, I’m really finding out how locked down AWS is the hard way!!! Am doing the docker container with pyramid and JUST got it working!! (Only took a week) my suggestion is that for future reference, to run uwsgi and nginx on a docker container use supervisor instead of systemd (which was in the 100webapps course), docker doesn’t like systemd for some reason.. or at least I couldn’t get it to work....
    Roger Ying
    @rogerying
    Question: is it a good idea to deploy mongodb in an aws ecs cluster?
    Scott Stoltzman
    @stoltzmaniac
    Any of the folks in here MongoDB users? I'm wondering if for an application I can use this...
    import datetime
    import mongoengine
    import bcrypt
    
    
    class User(mongoengine.Document):
        username = mongoengine.StringField(required=True)
        hashed_password = mongoengine.StringField(required=True)
        password_salt = mongoengine.StringField(required=True)
        created_at = mongoengine.DateTimeField(default=datetime.datetime.now)
    
        def generate_password(self, raw_user_password):
            self.password_salt = bcrypt.gensalt()
            raw_user_password = raw_user_password.encode('utf-8')
            self.hashed_password = bcrypt.hashpw(raw_user_password, self.password_salt)
            if self.hashed_password:
                return True
            return False
    
        def check_password(self, raw_user_password):
            raw_user_password = raw_user_password.encode('utf-8')
            hashed_password_check = bcrypt.hashpw(raw_user_password, self.password_salt)
            if hashed_password_check == self.hashed_password:
                return True
            return False
    
        meta = {
            'db_alias': 'core',
            'collection': 'users',
        }
    Scott Stoltzman
    @stoltzmaniac
    For clarification, I would be trying to use that on a flask app for user login/authentication
    Mukul Agrawal
    @mukul09
    hey guys. Can somebody help me with python regex. I want to uncomment the text in html. like if the text is <!-- My name is Mukul-->. I want the text as My name is Mukul using python regex. Thanks
    Jacqueline Wilson
    @jaclynn1_twitter
    You might be able to do that with BeautifulSoup
    vaibhavsolanki1193
    @vaibhavsolanki1193

    @vaibhavsolanki1193
    Hello All,

    I need some pointers from you good people.
    I have a certificate (PEM) file in text format and I want to extract information from it (for eg. Serial number, Issued to, Validity from and to).
    I have tried using RegEx but prefer not to use. I have gone through the SSL and X509 documentation but still not able to get it.

    Sample certificate:

    [
      Version: V3
      Serial Number: 640CA422E85F43403ED
      SignatureAlgorithm: SHA1withRSA (1.2.840.113549.1.1.5)
      Issuer Name: L=GB, ST=LN, CN=Labserver, OU=LAB, O=HSBC, C=GB
      Validity From: Sun Jul 08 12:22:43 BST 2018
               To:   Fri Jul 07 12:22:42 BST 2023
      Subject Name: L=GB, ST=LN, CN=Labserver, OU=LAB, O=HSBC, C=GB
      Key: RSA (1.2.840.113549.1.1.1)
        Key value: 3082010a02820101dc775da70aea5b1112e04bb810203010001
      Extensions: 3 present
      [
         Extension: KeyUsage (OID.2.15)
         Critical: false
         Usages: digitalSignature, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign,
      ]
      [
         Extension: ExtKeyUsageSyntax (OID.2.5.29.37)
         Critical: false
         Usage oids: 1.3.6.15.7.3.2, 1.3.6.1.5.5.7.3.5,
      ]
      [
         Extension: SubjectKeyIdentifier (OID.2.5.29.14)
         Critical: false
         keyID: e061d387fcb80c884952e3e
      ]
    
      Signature:
      0000: 39 8a a6 53 08 26 16 04 c1 71 79 d9 7c af a0 f1 [9..S.&...qy.|...]
      00e0: 91 ba e9 b9 62 74 0d fc be 70 fe b9 c7 b1 fb 69 [....bt...p.....i]
      00f0: 1a 36 31 5d c6 35 6b d8 1d b5 9b 02 7c 75 8e f9 [.61].5k.....|u..]
    
    ]-----BEGIN CERTIFICATE-----
    MIIDrTCCApWgAwIBAgIQZAykIuhfQ0A+0Ua+rHqDbDANBgkqhkiG9w0BAQUFADBm
    YSbSWRAiiG4o5zkj5ovXuhAKGUD6g/qpzmxL9RnH31swTbf9hbFVcsr9HKiimH1H
    5BgIixJuhE+Ww09MXIJY0e3dDuc9NsPk4G7/S0UActZ+Poq5fqt7dISqSy1srDoa
    QvVQonBvigbjAh0+nZDT1/Klp9TJbaxxn6TIsPFjb9TT1EzmeUeNBEofQOQlNC5X
    VJG66blidA38vnD+ucex+2kaNjFdxjVr2B21mwJ8dY75
    -----END CERTIFICATE-----
    Reason for not choosing regex: As I might be handling certificates from different vendor, the elements of the certificate might vary and cause the script to fail
    MarkDHarris
    @MarkDHarris
    Does anyone know why a flask app would run ok from the terminal using “python app.py” but the same app produces only 404’s when run with a vscode debugger launch configuration? I generated the configuration with the “add configuration" option and while it does seem to run it only produces log output like this: "127.0.0.1 - - [05/Jul/2019 12:01:49] "GET / HTTP/1.1" 404 -“
    MarkDHarris
    @MarkDHarris
    Actually, a better question is : what is difference between “python -m flask run” and “python app.py”? (the first leads to 404’s and the second works successfully in my case)
    Daniel Söderling
    @dsod
    Anyone else have problems using the training site? :)
    Michael Kennedy
    @mkennedy_twitter
    Hi @dsod Still having issues? It seems to be OK for me.
    @MarkDHarris Yes, there is a big difference. If you have some kind of code in the ‘main’ section, i.e. if name == ‘main1, that will not be run in the -m flask run way.
    Probably some sort of blueprints not getting registered or something, so the routes aren’t set, hence the 404.
    Daniel Söderling
    @dsod
    @mkennedy_twitter it seems to be ok now. Had issues with playing a video. Ty for response :)
    Michael Kennedy
    @mkennedy_twitter
    Hi @dsod It was actually being attacked with a DDOS. I managed to changes some things and fight them off (detected what they were pounding on and just stopped responding to them, which freed up the site to work for you all again). They eventaully realized it wasn’t working and went away.
    @rogerying MongoDB on an AWS cluster? Yeah, not bad. But you should explore MongoDB Atlas. It’s just that but they do all the tricky deploment, backup, upgrades, etc for you, on AWS. I would definitely use it if I were on AWS (I’m not :) ).
    Daniel Söderling
    @dsod
    Nicely handled, @mkennedy_twitter! DDOS
    Michael Kennedy
    @mkennedy_twitter
    Thanks @dsod !
    Roger Ying
    @rogerying
    Stupid question: how do u pass a variable from pyramid controller to template and then to be used either react.js or Vue.js... would u just simple do a <script>let var1 = ${variable_from_controller}</script> and use var1 in Vue or react main code which may be a separate js file? What’s usually best practice for this?
    Michael Kennedy
    @mkennedy_twitter
    @rogerying Yes, that’s exactly it. I just put a <script> tag at the top of the page, drop in the values into JS variables, then grab them in the scripts. For example, we round-trip your preferences for your video player on the courses this way. Whether you want closed-captions shown, etc.
    Rick Yentzer
    @ryentzer
    @rogerying That is NOT a stupid question. I've wondered the same! Something I've just not been able to wrap my brain around for some reason. :)
    Michael Kennedy
    @mkennedy_twitter
    Hi @rogerying and @ryentzer Here’s a little code to make things more concrete for you. This is the chameleon bits that drop the JS settings on the server side to be picked up by my player.js and related code (that video player is super JS heavy as you might guess):
        <script>
            var site = site || {}
            site.player = site.player || {}
            site.player_ctrl = site.player_ctrl || {}
    
            var debug = debug || {}
            debug.level = "${"dev" if view.dev_mode else "prod"}"
    
            var api_data = {
                'lecture': ${lecture.id},
                'ready': true,
                'next_lecture_url': '${next_lecture.play_url if next_lecture else ''}'
            };
            site.player_ctrl.preferences_state = {
                captions: ${'true' if preferences.captions else 'false'},
                quality: ${preferences.quality},
                speed: ${preferences.speed},
                ready: true,
                sync_off: false
            }
        </script>
    This is in the player chameleon file, notice this is a blend of JS and PYTHON. :) Here is the result on a page (for my settings).
        <script>
            var site = site || {}
            site.player = site.player || {}
            site.player_ctrl = site.player_ctrl || {}
    
            var debug = debug || {}
            debug.level = "prod"
    
            var api_data = {
                'lecture': 200501,
                'ready': true,
                'next_lecture_url': '/player/course/building-data-driven-web-applications-in-python-with-flask-sqlalchemy-and-bootstrap/lecture/200502'
            };
            site.player_ctrl.preferences_state = {
                captions: false,
                quality: 1,
                speed: 1.0,
                ready: true,
                sync_off: false
            }
        </script>
    Rick Yentzer
    @ryentzer
    That is helpful. So basically, your dropping in python variables into the js.
    Let's say I've built an simple employee list app. Name, email, date of hire are the only fields. Right now, I've built the front-end with jinja templates. If I wanted to instead use angular for the front end, do I use ajax calls to retrieve the data from myapp.com/employee-list?
    Michael Kennedy
    @mkennedy_twitter
    Hi @ryentzer Yes, that’s what I’m doing because I need a little server-side data to power the startup of the js app. There are still a handful of JSON-based APIs that the player calls as it does its job. So, for me, it’s a combo. Could also be a total plain JS launch then only APIs (as you’ve said) but I already have to render that page in Chameleon so might as well give the player the startup data while I have it. There is nothing private in there anyway.
    Rick Yentzer
    @ryentzer
    Very cool. Thanks for the insight.