GithubHelp home page GithubHelp logo

xoxo-back's Introduction

XOXO Game Project

This project will guide you through creating an API to manage scores for the XOXO game using FastAPI. The project consists of two phases:

  1. Connecting database(SQLITE) and API
  2. Creating a React UI

Game Description

In the XOXO game, we need an API connection to keep track of scores in a table. There are two players in each match. The score submission follows this format:

{
   "name": "JOHN",
   "status": "WIN"
}
{
    "name": "REZA",
    "status": "LOSE"
}
  • If the status is "WIN", find the player's score in the table and increase it by one.
  • If the status is "LOSE", find the player's score in the table and decrease it by one.

For each match, two records will be posted. For example:

  • JOHN | 2pt
  • REZA | 0pt

Phase 1: Connecting Database and API In this phase, you will create routes to:

  1. Get the top 10 players by rank.
  2. Post score and player name.

Phase 2: React and UI To be covered later.

2. Creating a Virtual Environment (.venv)

To create a virtual environment for your project, follow these steps:

  1. Open your terminal (command prompt, PowerShell, or any terminal you prefer).

  2. Create a virtual environment named .venv:

    python3 -m venv .venv
  3. Activating the Virtual Environment Activate the virtual environment to ensure that any packages you install are local to this project.

    • On macOS/Linux:
      source .venv/bin/activate
    • On Windows:
      .venv\Scripts\activate
  4. You should now see your terminal prompt prefixed with (.venv), indicating that the virtual environment is active.

  5. Installing FastAPI and Uvicorn With the virtual environment activated, install FastAPI and Uvicorn using pip:

    pip install fastapi uvicorn
  6. Running the FastAPI Application Create a file named main.py in your project directory and add the following code: JUST FOR TEST : from fastapi import FastAPI

    app = FastAPI()
    
    
    @app.get("/")
    def read_root():
        return {"Hello": "World"}
    
  7. To run the FastAPI application, use the following command:

    uvicorn main:app --reload
  8. visit http://127.0.0.1:8000/docs for Swagger UI

xoxo-back's People

Contributors

isamirmmd avatar phoenix15049 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.