Skip to content

cczw123/database_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

database_server

Overview

This project is a simple database server and API built with Python and Flask. It connects to a MySQL database, provides endpoints for updating and retrieving records, and serves data from a CSV file. It also includes integration with WeChat for token and openid retrieval.

Features

  • REST API using Flask
  • MySQL database setup and access
  • CSV to JSON conversion and MD5 hash checking
  • WeChat API integration for token and openid
  • Example client scripts for making requests

File Descriptions

  • app.py: Main Flask application, API endpoints, CSV handling, and database logic.
  • database.py: MySQL database setup and table creation.
  • access.py: WeChat API token and openid retrieval functions.
  • request.py: Example script to POST to /update endpoint.
  • request2.py: Example script to POST to root endpoint.
  • info.csv: Data file served as JSON via API.

Requirements

  • Python 3.x
  • Flask
  • mysql-connector-python
  • requests
  • MySQL server

Setup

  1. Install dependencies:
    pip install flask mysql-connector-python requests
  2. Ensure MySQL server is running and accessible with the credentials in database.py and app.py.
  3. Run the database setup (automatically called in app.py).
  4. Start the Flask server:
    python app.py

API Endpoints

  • POST /update: Update or get a record in the database. Requires JSON with id, activity, and token.
  • POST /mapdata: Get CSV data as JSON if MD5 does not match. Requires JSON with md5 and token.
  • POST /mini_id: Get WeChat openid. Requires JSON with usercode and token.

Example Usage

See request.py and request2.py for example client requests.

License

MIT License (add details if needed)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages