• Ptrst

    (@leitknightgaming)


    So I have a website here LKG that I am trying to recreate using wordpress. My current website has about two dozen python scripts most of which take an input supplied by the user and return various outputs. For example, the advantage page is a very small bit of code that rolls X amount of dice and gives you the average result.

    advantage code:

    def synergy(dice):
        from random import randint
        total = 0
        count = 0
        while count < 50000:
            lst = []
            rolls = 0
            while rolls < dice:
                tmp = randint(1,20)
                lst.append(tmp)
                rolls+=1
            high = max(lst)
            total+=high
            count+=1
        avg = total/count
        return avg

    The HTML if that helps anyone is

    <p>Used to see the average benefit from abilities like Stealth Synergy, War Sight, or simple Advantage</p>
        <p>How many dice are you rolling? Default 2:</p>
        <form class="stop" method="post" action="/advantage">
            <p><input class="stop" name="dice"></p>
            <p><input class="stop" type="submit" value="Run"></p>
        </form>

    I have the page set up so the html fields are there. I.E. how many dice and the run button is present. But I am a bit lost on how to take what someone enters into that field, feed it into the python code, and finally return the results. Any advise on methods, plugins, etc to solve this issue would be greatly appreciated.

    • This topic was modified 3 years, 3 months ago by Ptrst.
    • This topic was modified 3 years, 3 months ago by Ptrst.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • WordPress Runs on PHP, not python. I have an intranet site that uses java to send information to a mainframe computer. To get it to work, I created a PHP function that sends commands through a JAR file to the mainframe. The jar file takes the returned values and converts them into a JSON string and returns it to WordPress. I was also able to find a connector for java to allow for a connection with a database table and write content into the table. I used dbdelta to create and maintain the table in WordPress and a Custom WordPress loop to display the results. I created it almost 10 years ago and it still running and being used.

    Thread Starter Ptrst

    (@leitknightgaming)

    That sounds rather intricate. Is there a tutorial or some instructional videos covering this process? I don’t have a whole lot of experience with PHP.

    I don’t think there is a tutorial anywhere. You can make external calls to another program from PHP. I don’t use Python so I’m not sure what you need to do to return the values. I just played with code when I created my program. The Rest API wasn’t even being used at the time. You can take a short course in PHP. If you know any c based languages it should be pretty simple. You can create Object-oriented code or procedural code. It supports both.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Python Scripts’ is closed to new replies.