<commit_before>#!/usr/bin/python3

import sys
import json
import sqlite3

from flask import Flask
from flask import Response

app = Flask(__name__)

town_db_path = ""
cp_db_path = ""

town_db = None
cp_db = None

town_db_curs = None
cp_db_curs = None

def responseJson(res_json):
  data = json.dumps(res_json)
  return Response(data,
                  status = 200,
                  mimetype = 'application/json')

@app.route('/')
def hello_world():
  return 'Hello world!'

@app.route('/town/<int:id>', methods = ['GET'])
def town(id):
  global town_db
  global town_db_curs

  if not town_db_curs:
    town_db = sqlite3.connect(town_db_path)
    town_db_curs = town_db.cursor()

  town_db_curs.execute('SELECT id, name, name_tr, latitude, longitude, zoom FROM towns WHERE id = ?', [str(id)])
  row = town_db_curs.fetchone()
  json = None
  if row:
    json = {
                   "id" : row[0],
                 "name" : row[1],
              "name_rt" : row[2],
            "region_id" : row[3],
      "regional_center" : row[4],
             "latitude" : row[5],
           "longtitude" : row[6],
                 "zoom" : row[7]
    }
  else:
    json = { "id" : None }
  return responseJson(json)

@app.route('/cashpoint/<int:id>', methods = ['GET'])
def cashpoints(id):
  global cp_db
  global cp_db_curs

  if not cp_db_curs:
    cp_db = sqlite3.connect(cp_db_path)
    cp_db_curs = cp_db.cursor()

  cp_db_curs.execute('SELECT id, type, bank_id, town_id, longitude, latitude, address, address_comment, metro_name, free_access, main_office, without_weekend, round_the_clock, works_as_shop, schedule_general, schedule_private, schedule_vip, tel, additional, rub, usd, eur, cash_in')

  json = {
    "id" : id
  }
  return responseJson(json)

if __name__ == '__main__':
  if len(sys.argv) < 2:
    print("town.db file is not specified")
    sys.exit(1)

  if len(sys.argv) < 3:<commit_msg>[C|Server] fix: typos in keys in /town json response<commit_after>#!/usr/bin/python3

import sys
import json
import sqlite3

from flask import Flask
from flask import Response

app = Flask(__name__)

town_db_path = ""
cp_db_path = ""

town_db = None
cp_db = None

town_db_curs = None
cp_db_curs = None

def responseJson(res_json):
  data = json.dumps(res_json)
  return Response(data,
                  status = 200,
                  mimetype = 'application/json')

@app.route('/')
def hello_world():
  return 'Hello world!'

@app.route('/town/<int:id>', methods = ['GET'])
def town(id):
  global town_db
  global town_db_curs

  if not town_db_curs:
    town_db = sqlite3.connect(town_db_path)
    town_db_curs = town_db.cursor()

  town_db_curs.execute('SELECT id, name, name_tr, latitude, longitude, zoom FROM towns WHERE id = ?', [str(id)])
  row = town_db_curs.fetchone()
  json = None
  if row:
    json = {
                   "id" : row[0],
                 "name" : row[1],
              "name_tr" : row[2],
            "region_id" : row[3],
      "regional_center" : row[4],
             "latitude" : row[5],
            "longitude" : row[6],
                 "zoom" : row[7]
    }
  else:
    json = { "id" : None }
  return responseJson(json)

@app.route('/cashpoint/<int:id>', methods = ['GET'])
def cashpoints(id):
  global cp_db
  global cp_db_curs

  if not cp_db_curs:
    cp_db = sqlite3.connect(cp_db_path)
    cp_db_curs = cp_db.cursor()

  cp_db_curs.execute('SELECT id, type, bank_id, town_id, longitude, latitude, address, address_comment, metro_name, free_access, main_office, without_weekend, round_the_clock, works_as_shop, schedule_general, schedule_private, schedule_vip, tel, additional, rub, usd, eur, cash_in')

  json = {
    "id" : id
  }
  return responseJson(json)

if __name__ == '__main__':
  if len(sys.argv) < 2:
    print("town.db file is not specified")
    sys.exit(1)

  if len(sys.argv) < 3:
{'fraction_non_alphanumeric': 0.1307752545027408, 'fraction_numerical': 0.009397024275646046, 'mean_word_length': 3.0209863588667365, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7359304', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1369, 'n_words': 327}