How to Create a Free Membership Site with Web2py (with copy and paste template)

Give us our membership site - Oh Yeah!
Would you like a free membership site?

Membership sites are pretty darn awesome, because:
  • you can make a paid mobile app
  • you get a "caged environment" of people who are enthusiastically looking for help that you can then give paid assistance to - either actively or passively
And they're even better if:
  • you can integrate stripe into it
  • it's mobile friendly
But the problems are
  • they're a lot of effort to set up
  • pre-prepared ones are probably going to be expensive
  • making sure security is set up properly can be dodgy - especially when it comes to money
How do I know all this? Because in early 2017 I figured...

Making a Membership Site is Really Easy - Right?

My name is Robert Angelo, and I am NOT a computer programmer. I'm a physiotherapist, which is about as opposite to being a computer programmer as you can get, unless you're a professional Norweigian Clog Dancer.

And I spent blinkin' ages on this.

Some of my failures include

  • Learning Java on Android - and then completely abandoning it
  • Spending weeks on Mautic, trying to force it to bend to my will - and then abandoning it
  • Learning HTML5 / Javascript - and then abandoning it

(you may be picking up a pattern here)

The lowest point was when I looked back and realised I'd spent 3 months on this - and I was still just beginning. I was so disheartened I drowned my sorrows in tea and watched 3 consecutive episodes of Coronation Street.

I woke in the morning facing a harsh reality: I had just drunk tea and watched 3 consecutive episodes of Coronation Street. The psychological damage (and direct brain damage) that this had caused me was incalculable.

But perhaps the brain damage had knocked some sense into me at the same time. Perhaps.

But this was when I knew...

There IS a way to Getting Everything You Want in a Membership Site!

Through sheer grunt and hard grunt-ism, I managed to create the foundation.

And with that, my results started to trickle in.

I made my first mobile app website with paid membership in April 2017...

and I remember the first person who played it - it was my brother, Jon.

He said it was crap.

But I didn't care. The feedback and tweaking and changing to make it work were what I was after. I wanted a viable game/app that actually helped people, and I knew that the only way I could achieve that was lots of feedback, upgrades and improvements.

And then this happened...

The spare lamborghini
Long story short, now I have a billion dollars, I loll around my mansion in my underpants smoking Cuban cigars and drinking whiskey, and that's when I'm not lolling around my lamborghini in my underpants smoking Cuban cigars and drinking whiskey.

So here's a gentle question...

Would you like all the code, template-ized for the mobile site?

Just a few quick points first:

  • This is a quick one, It's (extremely) ugly and basic, but should give you a framework to figure out from
  • I did it on pythonanywhere for free which is pretty cool. The template below should work on local or others though
  • No email out or $ (stripe integration) because the pythonanywhere free version doesn't allow that. But at the current time (2017) it's only $5/mth to upgrade and that should enable you to do that. Dunno yet cos haven't tried it
  • (looked at GAE but the pricing seemed so complicated I couldn't figure it out in the 14 seconds I spent looking at it)
  • To access the members list it's under app admin - note web2py does a lot of the setting up of tables and stuff for you
  • I had to put the auth setting stuff in the controller because I couldn't get the re-directs to work any other way. (frustrating as heck)
  • Also the views are not b1 or b2, they are e/b1 or e/b2 so that it's created in a folder. (These caught me out for a long time)
So this is what it looks like...

Anyways...

 To access, go to https://XXXXXX.pythonanywhere.com/c/e/b1  
   
 Create App: C  
   
 Create Model: a.py  
 ..................................................................  
 db = DAL ('sqlite://storage.sqlite')  
 from gluon.tools import Auth  
 auth = Auth(db)  
 auth.define_tables(username=False,signature=False)  
 ..................................................................  
   
 Create Controller: e.py  
 ..................................................................  
 #to access, go to https://XXXXXX.pythonanywhere.com/c/e/b1  
   
 #setting stuff  
 auth.settings.controller = 'e'  
 auth.settings.on_failed_authorization = URL('e', 'b1')  
 auth.settings.login_url = URL('b3')  
   
 #home page  
 def b1():  
   display_page = XML('<h1>Home Page</h1><a href="b2">Registration</a><br><a href="b4">Login to members</a>')  
   return dict(display_page = display_page)  
   
 #regn page  
 def b2():  
   display_page = XML('<h1>Registration Page</h1><a href="b4">or Skip this page and Login to members page</a>')  
   return dict(display_page = display_page, form=auth.register(next=URL('b4')))  
   
 #login page  
 def b3():  
   display_page = XML('<h1>Login Page</h1>')  
   return dict(display_page = display_page, form=auth.login(next=URL('b4')))  
   
 #members page  
 @auth.requires_login()  
 def b4():  
   display_page = XML('<h1>Members Page</h1><a href="b5">Logout</a>')  
   return dict(display_page = display_page)  
   
 def b5():  
   display_page = XML('<h1>Logging Out</h1>')  
   return dict(display_page = display_page, form=auth.logout(next=URL('b1')))  
 ..................................................................  
 Create a new view: e/b1............  
 {{=display_page}}  
 ................................  
 Create a new view: e/b2............  
 {{=display_page}}  
 {{=form}}  
 ................................  
 Create a new view: e/b3............  
 {{=display_page}}  
 {{=form}}  
 ................................  
 Create a new view: e/b4............  
 {{=display_page}}  
 ................................  
 Create a new view: e/b5............  
 {{=display_page}}  
 {{=form}}  
 ................................  

Good resources:


So there you are!
Take this, go forth and use it.
And if you make a billion dollars from it, you owe me a beer.

No comments:

Post a Comment