Skip to content

mouniesa/CTPy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues GPLv3 License Last Commit


Logo

Capture The Python

CTPy is a series of Capture the Flag styled challenges for Python learners


Table of Contents
  1. Getting Started
  2. Usage
  3. Troubleshooting
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

Getting Started

Prerequisites

The following external dependencies need to be pre-installed in order to host your own CTPy game server.

  • Python 3.6 +
  • flask
    pip install flask

Installation

  1. Clone the repo and cd into the folder
    git clone https://github.com/solamarpreet/CTPy.git && cd CTPy
  2. Start the game server
    python3 server/ctpy-server.py
  3. Open a new terminal and start the Python shell
    python3
  4. Import the ctpy.py file into the Python shell
    from ctpy import *
  5. Fetch Question 1 and start playing :)
    game.question(1)

Usage

In order to play you need to make use of the 'game' object that has already been initialized for you. This 'game' object has 3 methods available which you need to use:

game.question()

This method pulls the question text from the server and displays it on the console. It accepts one parameter i.e Question Number

game.question(1)

game.data()

This method fetches the data associated with the Question. It accepts one parameter i.e Question Number

game.data(1)

game.answer()

This method submits your answer to the server and returns a string telling you if your answer was correct or incorrect. It accepts 2 parameters i.e The Question Number you are submitting the answer for and the answer itself.

game.answer(1, 'This is the answer')

or

game.answer(1, x)
# where x is a variable containing the answer

or

game.answer(1, myfunc())
# where myfunc is a function that calculates the answer

(back to top)

Troubleshooting

If you get an error stating '[Errno 111] Connection refused' then it is possible that Flask started the HTTP server on a non default port.

In that case check the terminal output you get after you run the Step 2 of the Installation process. Take a note of the port number and make the change in the last line of ctpy.py file as follows

# game = Game('http://127.0.0.1:5000')
game = Game('http://127.0.0.1:<your-port-number-here>')

If that does not help address your issue check the open issues for a list known issues and open a new issue.


Roadmap

  • Dynamic question data to ensure solutions are obtained in a programatic fashion
  • Segregated beginner, intermediate and advanced challenge paths

Contributing

Please contribute additional quality questions/challenges so that Python beginners can continue to benefit from this project.

If you have a question that you wish to add, simply open an issue with the tag "question". You can also fork the repo, add your code and create a pull request.


License

Distributed under the GPLv3 License. See LICENSE for more information.


Contact

Amarpreet Singh - [email protected]

Blog & Portfolio : https://solamarpreet.github.io


Acknowledgments


(back to top)

About

A series of 'Capture The Flag' styled Python challenges

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%