<commit_before>#!/usr/bin/python

import sys
from flask import Flask, request
from pymongo import MongoClient
app = Flask(__name__)

dbname = ""

@app.route("/<collection>", methods=['POST'])
def collect(collection):
	try:	
		client = MongoClient()
		db = client[dbname]		
		db[collection].insert(dict(request.form))
	except Exception as ex:
		app.logger.error(ex)
		return str(ex)
	return ""

if __name__ == "__main__":
	dbname = sys.argv[1]
	app.run(debug=True)
    <commit_msg>Hopefully problems with lists being passed as data solved.<commit_after>#!/usr/bin/python

import sys
from flask import Flask, request
from pymongo import MongoClient
app = Flask(__name__)

dbname = ""

@app.route("/<collection>", methods=['POST'])
def collect(collection):
	try:	
		client = MongoClient()
		db = client[dbname]		
		copy = dict()
		for key, val in request.form.iteritems():
			try:
				app.logger.debug(str(key) + " " + str(val))
				copy[key] = "".join(val)
			except ValueError:
				pass
		app.logger.debug("Adding " + str(copy))
		db[collection].insert(copy)
	except Exception as ex:
		app.logger.error(ex)
		return str(ex)
	return ""

if __name__ == "__main__":
	dbname = sys.argv[1]
	app.run(debug=True)
    
{'fraction_non_alphanumeric': 0.14722911497105046, 'fraction_numerical': 0.0016542597187758478, 'mean_word_length': 4.1931330472103, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '7503636', 'n_tokens_mistral': 460, 'n_tokens_neox': 424, 'n_words': 103}