<commit_before>package api

import (
	"database/sql"
	"encoding/json"
	"io/ioutil"
	"net/http"

	log "github.com/Sirupsen/logrus"
	"github.com/ericflo/gradientzoo/models"
)

func HandleFileUpload(c *Context, w http.ResponseWriter, req *http.Request) {
	username := c.Params.ByName("username")
	slug := c.Params.ByName("slug")
	framework := c.Params.ByName("framework")
	frameworkVersion := req.Header.Get("X-Gradientzoo-Framework-Version")
	filename := c.Params.ByName("filename")
	clientName := req.Header.Get("X-Gradientzoo-Client-Name")

	decoder := json.NewDecoder(req.Body)
	var metadata map[string]interface{}
	if err := decoder.Decode(&metadata); err != nil {
		msg := "Could not decode metadata"
		log.WithField("err", err).Error(msg)
		c.Render.JSON(w, http.StatusBadRequest, JsonErr(msg))
		return
	}<commit_msg>Fix the way metadata is parsed<commit_after>package api

import (
	"database/sql"
	"encoding/json"
	"io/ioutil"
	"net/http"

	log "github.com/Sirupsen/logrus"
	"github.com/ericflo/gradientzoo/models"
)

func HandleFileUpload(c *Context, w http.ResponseWriter, req *http.Request) {
	username := c.Params.ByName("username")
	slug := c.Params.ByName("slug")
	framework := c.Params.ByName("framework")
	frameworkVersion := req.Header.Get("X-Gradientzoo-Framework-Version")
	filename := c.Params.ByName("filename")
	clientName := req.Header.Get("X-Gradientzoo-Client-Name")
	metadataString := req.FormValue("metadata")

	var metadata map[string]interface{}
	if err := json.Unmarshal([]byte(metadataString), &metadata); err != nil {
		msg := "Could not decode metadata"
		log.WithField("err", err).Error(msg)
		c.Render.JSON(w, http.StatusBadRequest, JsonErr(msg))
		return
	}
{'fraction_non_alphanumeric': 0.16193853427895982, 'fraction_numerical': 0.0, 'mean_word_length': 5.317164179104478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '630143', 'n_tokens_mistral': 598, 'n_tokens_neox': 583, 'n_words': 106}