r/learnpython • • Nov 19 '19

My first application!

In October I started my Python-journey, with a full time job and a 2yo kid the spare time is scarce.
I've been following a Udemy-course and also used some android-apps to just study something every day.
2 weeks ago I made my first real script from scratch, I had a idea of automating / helping with a tedious task at work. I'm a train driver, and every train we start we fill a paper form, check some values from 2 different paper lists and enter some of that data into the control computer.

The script were terminal based and did all the calculations I wanted, checked up the values from those 2 lists (one which is short, so I just made an elseif of it, the other is long so I made a .txt with the values) and gave a summarized result.

Now 2 weeks later I've deployed it on the web with Flask to be able to share with my colleges!
With dropdowns, forms to fill and a button to run the scripts and show the result.

Thanks to inspiration from this subreddit (and others) I made it working! It's plain ugly, but the functionality is there. Guess I'll come back and sort the design with bootstrap or at least some css'ing next time I feel a dip in the studying.

I dno if there's a better way to post a image, but here's one:
Image of the result with explanations

407 Upvotes

72 comments sorted by

46

u/TrueBirch Nov 19 '19

This is a great project! And I actually like the interface.

14

u/Mag37 Nov 19 '19

Thank you! It was a fun path, starting with the idea, what values did I need to present, what to do with them? Working out one function at a time. Then making it smarter and slimmer the more I worked on it. Also asking my colleges if they'd use a tool like this, what would they like to see.

9

u/Hudlommen Nov 19 '19

I once made a handover sheet for the ward a worked at, because they just did it in word and people kept fucking it up. They ended up using it way past i left the place, only stopping because they somehow manage to break it in the end :D - But just as a word of caution, i had little to no traction in the beginning, people are just very hard to get to change their mind. So if you meet push-back, its not you or your idea, just people..

Great work!

6

u/Mag37 Nov 19 '19

Thanx! Cool that they kept using it :) I've got no intention for this to be used by the company, that wasn't the idea from start. Started with it in the terminal for fun, and then when I actually made it work I wanted to show my close colleges - so had to get it to work on cellphones. We'll see how they like it and if I keep working on it!

20

u/Conrad_noble Noble1988 Nov 19 '19

Your story sounds so much like my own apart from I'm yet to finish any project.

Your story is an inspiration to me.

11

u/Mag37 Nov 19 '19

Haha! I've heard so many times in YouTube videos "Just build on your personal projects while you learn!" but I just couldn't come up with anything relevant to build on.. Until I stumbled on the idea of automating something in my job, which otherwise is very none-office like. You'll find something that motivates you, could be anything! Something really simple, or something complex that you just start sketching.

Thank you!

2

u/[deleted] Nov 19 '19

Did you start as a complete newbie? 6 weeks is incredible!

I have a project in mind but it has meant learning Pandas and Dash which has added a lot of time.

You've inspired me to keep going.

3

u/Mag37 Nov 20 '19

Well kinda yes, I've always been quite tech savvy, only been doing some minor web and scripting from time to time because of necessity, but then mostly copy-pasting, using pre-built stuff, templates and other people's work. Never really understanding any language, creating from ground up.

I did some basic pandas in the Udemy course, seems like there's a lot to learn but also a lot of potential!

You'll make it! Just start small and ugly, it'll grow larger and you'll figure out smarter way to redo things along the way!

0

u/[deleted] Nov 20 '19

[deleted]

2

u/Mag37 Nov 20 '19

Haha thank you, I will keep studying on the side, see where it leads :)

3

u/Conrad_noble Noble1988 Nov 19 '19

thank you, keep up the good work.

0

u/[deleted] Nov 20 '19

[deleted]

1

u/Conrad_noble Noble1988 Nov 20 '19

I would give you feedback but I haven't got a clue what it is or what it does.

8

u/catconsultant Nov 19 '19

That’s awesome! What udemy course did you go through?

13

u/Mag37 Nov 19 '19

Thank you! I'm not done yet but maybe 80% completed, I'm doing "The Python Mega Course: build 10 real world applications" with Ardit Sulce. I've found it good to go thru a lot of different aspects of Python and how to use them in different areas. Just basics, but still good fundamentals.

1

u/flabcannon Nov 19 '19

Do you think you will be able to to actually build these applications using the course or are the videos more like walkthroughs of him developing the code?

4

u/udeogratias Nov 20 '19

Hi! I'm currently taking this course. The course's approach is more tutorial-like, so basically the videos contain all the code one needs to get the applications running with few practice tasks along the way.

2

u/Mag37 Nov 20 '19

Indeed, I felt it's very easy to follow along and you can more or less just copy the code of the screen. But I'd suggest you try to change it, write it a different way, add different attributes and parameters. Just to know what it actually does. The applications themselves are very basic and more just a preview or startup of different areas of Python development.

2

u/flabcannon Nov 20 '19

Thank you! Great job on the GUI btw - I like the look of it.

1

u/flabcannon Nov 20 '19

Thanks! This is encouraging news - I'll look up this course on udemy.

2

u/ReachingForVega Nov 20 '19

+1 for the course, you actually build the apps step by step. You will be surprised.

2

u/flabcannon Nov 20 '19

Thank you - that's the kind of training I was looking for so will check this course. I have gone through quite a few beginner courses which make big promises but end up taking you to the same plateau and leaving you there.

2

u/ReachingForVega Nov 20 '19

My personal experience is doing ATBS then doing this course with work projects in mind.

The secret to learning python is practice solving problems with projects.

2

u/flabcannon Nov 20 '19

Thanks - I've done about 60% of Python Crash Course so far but still need to make the jump to larger scale projects.

2

u/ReachingForVega Nov 20 '19

I don't think scale is necessary but putting learnings together.

Things like:

  • Call SQL and get data

  • Save to file

  • Open data in pandas

  • Manipulate data

  • Make pretty graphs

  • Save or distribute

You've built a report.

2

u/flabcannon Nov 21 '19

You're right - I should stop and think about the steps involved in the code flow like this more.

2

u/ReachingForVega Nov 21 '19

You can do it. Just break down your tasks or chunks into functions. Draw it out before you code.

→ More replies (0)

4

u/squidensalada Nov 19 '19

Very nice! I’m a beginner doing something similar for a scientific field. Gives me some hope!

4

u/Mag37 Nov 19 '19

Thank you! I struggled a lot to get the json-object response to work and show the result as I liked, as I don't have no JS/Ajax experience at all. But the python bits felt good!

3

u/toursick Nov 19 '19

Nice. Typo “weigth” on a few things :)

2

u/Mag37 Nov 19 '19

Indeed, thank you! The English version was just a quick re-write of the original, should've looked over my "weigth"s, common typo from me!

2

u/excelnotfionado Nov 19 '19

This is really nice to see because I'm working on multiple projects at work but looking to make small, deployable python applications for my colleagues as I learn. You rock!

1

u/Mag37 Nov 19 '19

That's great! Keep it up and if you got one or two you trust extra well, just bounce the ideas and half-done projects with them? Thanks! You too!

2

u/IsReadingIt Nov 19 '19

Perhaps you could do a printout of the calculations at each step you are doing behind the scenes. A "show your work" kind of thing that would give your coworkers confidence in the calculations.

1

u/Mag37 Nov 19 '19

Thank you, it's a good suggestion. If it comes to me sharing this with more than my friends among my colleges, I'll certainly need to show what I've done and I need to work in some more error handling.

2

u/TaryTarp Nov 19 '19

Good job!

Don't worry about the ugliness, it works, that's what matters.

I have seen a lot of internal applications that look similar to yours ;).

1

u/Mag37 Nov 19 '19

Thank you! I'll leave it as it is for now, thinking of bootstrapping it later to make it responsive for use on phones etc.

2

u/404delerium Nov 19 '19

Congratulations, that is so awesome! I love the feeling when you find something to automate, and the more we learn, the more we can automate. Thank you for sharing your project!

2

u/Mag37 Nov 20 '19

Thank you! Lately when my wife have been mentioning stuff she does in her job I'm like "Do you need to do that often? Is it usually the same? I could automate that!". But have yet found something worth, hopefully soon thou!

Thank you for commenting, wasn't sure I'd post first, but I've felt inspiration from browsing through this sub and the stories of others.

2

u/404delerium Nov 20 '19

I and other appreciate your story! I hope you find some awesome things to automate (as I will continue searching to as our skills increase) :)

2

u/mangoed Nov 19 '19

I'm more impressed by a Flask application than calculations. Learning Flask seems more time-consuming than learning the basics of Python.

1

u/Mag37 Nov 20 '19

The Flask bit was tough, still not entirely sure I understand it and I don't even use the blocks and connections, it's only one page! I'll look into expanding it a tiny bit with some bootstrap and maybe a header or so with links. But it's doable, there's a lot of good videos on Flask depending on what you want to do. It'd be good to have some better understanding of JS and html than I do thou ^ to make something nice.

2

u/mangoed Nov 20 '19

Thanks! One of my next goals is to replace some of the WordPress sites that I manage with Flask apps, mostly because I hate PHP (especially for larger projects), and although there is a huge number of WP plugins available for any imaginable task, sometimes it's still difficult to get exactly what you want. I guess that I would have to learn a lot before I can do that with Flask, I think I already found all the resources that I need, just need to spend more time learning stuff.

2

u/nathanieloffer Nov 20 '19

Mate you should be seriously proud! With a full time job and a young child you've taken an idea and come up with something good enough you are able to rely on it at work and share it with your colleges! Nicely done.

1

u/Mag37 Nov 20 '19

Thank you - I'm taking the opportunity to study when I can, and the work on this sideproject have grown bit by bit I my head and in notes, then completing and working out as much code as I can when I manage to get a sit down. Now back to completing the course and thinking of a new project :)

3

u/Pepe_Silvia96 Nov 19 '19

congrats. I've been trying to learn nginx/gunicorn so if you don't have any sensitive information in the project I could deploy it on google cloud for you if you'd like.

4

u/Mag37 Nov 19 '19 edited Nov 19 '19

There's nothing sensitive in it, I'd gladly share it with you if you'd like to practice on it, thou I've deployed it already on http://mag37.pythonanywhere.com edit: excuse the Swedish thou, as I've deployed it for my colleges ^

2

u/Hudlommen Nov 19 '19

You can also have a look at things like Kivy for GUI (if needed)

3

u/Mag37 Nov 19 '19

Good tip! I was considering gui first, but I think I'll keep this project web-based. Thou surely gonna try Kivy for something else in the future.

2

u/Hudlommen Nov 19 '19

I know what you mean, i have also left gui out for much of my programming. Im more of a script person and the gui just takes up time you could be using on programming more functionality. When you at some point are using tkinter, just start using Kivy instead. Its much newer and better, and the basics programming is almost the same as tkinter anyways. BUT it is a bit more difficult to install and compile.

1

u/[deleted] Nov 19 '19

I'm completely new to programming. I have no idea. Would you recommend the course that you have taken? Because I really want to learn programming. How well the basics are taught in this course?

1

u/Mag37 Nov 19 '19

I'm completely new too, thou I've dipped my toes now and then for hobby projects, both in web and minor scripting. But never really grasped basics or learnt to create anything. I think this course is really good for getting started, getting a feel for the language and the different fields it can operate in! Give it a go if you find it cheap on Udemy, there's sales all the time!

My biggest tip thou, no matter how you try to learn, don't just code along, copying the screen/book. Try changing some bits, see what happens, personalize it, give it a different result.

1

u/[deleted] Nov 19 '19

I really want the basics. Like all the basic stuff. Once I learn the basics I will look after this course. Thanks!

1

u/Mag37 Nov 19 '19

He covers the basics quite well and the course is set for people with no prior knowledge. I found it for like 9$ or less when it was a sale.

2

u/[deleted] Nov 20 '19

Sure. Thanks!

1

u/johnne86 Nov 19 '19

Awesome! I’m attempting a similar project for myself to help organize some work stuff. I’m in Tech Support and right now all our documentation about the various sites we manage is spread across multiple spreadsheets and word docs. I’m basically trying to create a directory of information to help pull this info quicker. Enter a site name, select a few options and it spits out all the relevant information. It could probably all be in a database, but I want it to be in Python. I actually like that my gui is just CLI right now, it makes it seem like a smaller portable tool which is what I want right now.

How did you program the buttons, combo box drop down menus and such in your flask app? Is that coded in HTML/JS logic?

I wouldn’t mind to learn how to populate combo box’s with choices and then have the info you select show up in a text box.

2

u/Mag37 Nov 20 '19

Oh that's a great idea! There's a bunch of smart ways of gathering information in Python that I think will come in handy. You can always populate your own csv file or database with collected information as well, depending on if it's changing or static. And then work from that csv/database with your app.

The dropdowns and forms are in html with a variable that's get sent to the python side to be used in the calculations, like this:

<select class="form-control" id="engine_1" name="engine_1">

        <option value="1" selected>RC4/RD2</option>

        <option value="2">RM</option>

        <option value="3">RE</option>

    </select>

And then in the python code you can use it however you want, like I've used it: if engine_1 ="1": do this.

I'd love to share this learning experience with other people in the same general level. I think you learn a lot by bouncing ideas and solving stuff. Give it a go! Just try with something that seems the easiest and build up from there.

2

u/johnne86 Nov 20 '19

Thanks a lot! I'll have to look more into that HTML web interfacing for Python. Seems great for building UIs. I have a lot of HW to do, but it has been fun learning Python!

1

u/algebraic94 Nov 20 '19

Awesome job! One thing I'm curious about as I am now developing with Flask. Where are you hosting the app? Like what server space are you using? That part always confuses me.

1

u/Mag37 Nov 20 '19

Right now it's running slow on the free version of http://pythonanywhere.com

But I'll look into where I can deploy it next, there's some hosts that don't support python and some who does. Another user mentioned Google cloud here in the comments.

1

u/[deleted] Nov 20 '19

Wow I have been studying Python back and forth for about 2 months and can barely do something lol

2

u/Mag37 Nov 20 '19

Well to be honest, I wouldn't be able to remake anything from the course just from my head, if I didn't look at notes or google'd. I guess, as with all things, it takes time and practice to actually learn :) but the more you look something up and the more you try it, the more will stick! Keep it up.

1

u/[deleted] Nov 21 '19

Honestly this is something that could be achieved with Excel, it's pretty powerful. Have a look at the Excel functions IF & VLOOKUP, and then make it available to your colleagues on google docs.

There's no need to pay for the servers and build a web app here.

1

u/Mag37 Nov 21 '19

It's not for production, it's for studying and motivating myself to learn. It could indeed be done with excel or just a simple JS-page for most of the functions, but I'm learning Python so I wanted to make it all in Python.

There's already a web app built and I won't pay for servers :) It was just a fun and motivating project to get myself trying to produce something.

1

u/[deleted] Nov 21 '19

Fair enough. But programming is also about finding the best technology to achieve something. Here there are some fairly simple computations, and you wanted to share them with your colleagues, so excel on google docs is well suited for that. Anyway, keep at it.

1

u/Mag37 Nov 21 '19

I totally agree with that, the fundamentals of programming is indeed to find the best way to solve a problem.

But the goal here was to use my new knowledge in a programming language I've studied for less an hour a day last 2 months and build something myself, not only from tutorials. I chose this project because it motivated me - if I completed it my regular job with also become easier, but that was just a bonus. To share it with colleges was never the point, never the goal.

And even so, no matter if theres a situation where Method A would solve something more effective than Method B.. If I don't have any knowledge for Method A but know how to solve it with Method B - then B is the best technology for me.

3

u/makaronincheese Nov 19 '19

my admiration!

1

u/DrShocker Nov 19 '19 edited Nov 19 '19

This is great. I love every opportunity to have computers do more of our work as people.

with the work this does, you may want to consider the liability you're possibly taking on if someone you share it with uses it incorrectly, or if there's some edge case you didn't account, etc. I am not a lawyer, so it might not be an issue at all, just protect yourself is all I'm saying.

1

u/Mag37 Nov 19 '19

Thank you kindly, I've got a couple of colleges testing it on the side as writing up the regular forms, to make sure it translate and calculate right. But you're right, if I consider sharing it widely I'll probably add a "does not replace form ##" etc. It's a very good point as this is part of the safety measurements we take.

2

u/[deleted] Nov 19 '19

Wow wonderful 😊😊😊

2

u/[deleted] Nov 19 '19

Wow man...good for you!

2

u/ReachingForVega Nov 20 '19

Well done - I want to build my apps into flask at work also but I have to work around our IT's red tape.

The day I build my first reporting tool, I felt as proud as you. Now onwards to your next app!

2

u/[deleted] Nov 20 '19

That first cool, working app feeling is great. Congrats!