My First Project - Part 1
My first steps
The project
As mentioned in My introduction, my first project using Python was a gaming website for a massively-multiplayer online role-play game (MMORPG). I had started a corporation in-game (a player group/guild) and was keen on providing the other members with some out-of-game tools that other larger groups did. The game developers (CCP Games) have a host of information that players can access from the game server through various API requests, some require authentication, some you can just grab. It was this sort of information that I wanted to be able to conveniently supply to my corporation members.
This series describes the journey from this initial idea to the deployment of my first full Python application.
- Part 1 - My first steps (this post)
- Part 2 - My first tutorial
- Part 3 - My first deployment
Project idea
Site requirements
I had a few initial requirements for the website and what I was setting out to achieve:
- Logins were to be handled using the Eve Online SSO system (rather than a local user system).
- The website would not be hardcoded specific corporations, characters or anything similar, rather any corporation could log in and use it for themselves, without sharing that information to other corporations.
- Corporation information was to be pulled from the server, either upon request or periodically, nothing should be manually entered
- The website would have to be able to determine if the logged in character was allowed to see the corporation information (Eve Online is notorious for having spies, so some method of authorising specific characters to view specific information was required).
Tools used
As this was my very first Python project, I didn’t know at the time what tools to use but, as I was following along with a tutorial (more on this in the next post), I used the same as the tutorial:
- Python 3.6
- PyCharm
- SQLite (development) / MySQL (deployment)
- Main python packages:
- Flask, using Jinja2 templating
- WTForm
- SQLAlchemy
- DigitalOcean (for remote server deployment)
Baby steps
I knew the (very!) basics of reading and writing HTML and so I roughed up a basic concept and layout of what I’d like to be able to do but soon found out just how limited my skills were. I remember one of my first early successes being that I managed to show the official Eve Online login button on my rough sketch by linking to the CCP Games resources page. Yes, that’s how little I knew to begin with!
(initial html rough up done)
With some more research I found some examples for how to work with the games SSO (single sign on) system that was used to gain access and authorisation to the game server information. But this information had to be requested, parsed and loaded in to whatever form that I required it to be in, and that was excluding things like built in error checking, authorisations and other things that I had zero clue about. The CCP Games have a very good relationship with third-party developers and they have a lot of resources available, and some examples on how to use the SSO system. Thankfully, it was also written for Python!
The first goal that I had set was to be able to login with my Eve Online credentials and get some basic character information. This meant learning a BUNCH of new terms and ideas, one of which was the JSON data format. I’d seen similar style data formats before, but I’d never heard of, nor used, JSON before. After reading up, and looking at some example JSON formatted data from the Eve Online resources page examples, I started to piece it together. As I hadn’t done anything about setting up the database yet, all of this process was manually hardcoded to the Python files (yes, yes, not the best practice I know).
By the end of this first step, I was able to:
- Create the login URI using my application client id (setup on the Eve Online developers page)
- Successfully login in using my Eve Online credentials
- Get the authorisation token from the resulting callback
- Use the authorisation token provided to request the token information from the Eve Online server
- Take the resulting data response from the server and get the character’s name and unique ID number
Success…?
As excited as I was after accomplishing this goal (and by no means was this a first attempt!! This was a slow process getting to this point), it soon became clear that there was a lot more to do and that, even though I had this information, I had zero clue what to do with it from here. How did one store and recall this information permanently?
At this point though, I had definitely caught the bug! Seeing a plan come together and to be able to create something that worked? That was a pretty powerful, no matter how dodgy the code I wrote actually was. So, I knew I definitely wanted to continue, however I wasn’t sure how. I also knew that I desperately needed better guidance and had also started to realise that this was a big project: creating a website (mostly) from scratch.
Knowing what you don’t know
I’m not entirely sure how other people go about learning new things in adulthood, but my preference is to follow along with something like a tutorial or course to get a baseline (I do love a solid baseline) and then copy and expand on that idea or method from there.
For me, doing things this way helps answer questions that you don’t even know that you should be asking at the time. With something as complex as a website (things have changed since my Geocities profile page experiments!) I knew that there would be a hoard of things that I needed to learn about but would not have had any clue where to begin.
So, I needed to find a good tutorial that was going to be able to get me started from a very (VERY!) basic level but detailed enough to see me through to the project end (or as close as possible). I did as all modern day ‘researchers’ did, and Googled some stuff…
Luckily this lead me to finding the Holy Grail of beginner Python tutorials: Miguel Grinberg’s ‘Flask Mega-Tutorial’.
Lessons learned
Just start!
The biggest lesson from this initial step was just get started. There are so many things that you can try plan, research, worry about, etc, that it can be overwhelming. I barely had any clue where to being but finding one small idea and starting with that appeared to be enough for me to get going.