<commit_before># tested with python2.7 and 3.4
from spyre import server

import pandas as pd
import json

class UserUploadApp(server.App):

	def __init__(self):
		# implements a simple caching mechanism to avoid multiple calls to the yahoo finance api
		self.data_cache = None
		self.params_cache = None

	title = "Historical Stock Prices"

	controls = [{	"type" : "upload",
					"id" : "ubutton"
				},
				{	"type" : "button",
					"label" : "refresh",
					"id" : "update_data"}]

	tabs = [ "Text", "Table", "Plot"]

	outputs = [{	"type" : "plot",
					"id" : "plot",
					"control_id" : "update_data",
					"tab" : "Plot",
					"on_page_load" : False },
				{	"type" : "table",
					"id" : "table_id",
					"control_id" : "update_data",
					"tab" : "Table",
					"on_page_load" : False },
				{	"type" : "html",
					"id" : "html1",
					"control_id" : "update_data",
					"tab" : "Text"}]

	def __init__(self):
		self.upload_data = None
		self.upload_file = None

	def html1(self,params):
		text = "Upload a CSV and press refresh."
		if self.upload_data is not None:
			text = self.upload_data
		return text

	def storeUpload(self,file):
		self.upload_file = file
		self.upload_data = file.read()

	def getData(self, params):
		df = None
		if self.upload_file is not None:
			self.upload_file.seek(0)
			df = pd.read_csv(self.upload_file)
		return df

if __name__ == '__main__':
	app = UserUploadApp()
	app.launch()<commit_msg>removed copy-pasted code from user_upload_example<commit_after># tested with python2.7 and 3.4
from spyre import server

import pandas as pd
import json

class UserUploadApp(server.App):

	title = "Custom File Upload Example"

	controls = [{	"type" : "upload",
					"id" : "ubutton"
				},
				{	"type" : "button",
					"label" : "refresh",
					"id" : "update_data"}]

	tabs = [ "Text", "Table", "Plot"]

	outputs = [{	"type" : "plot",
					"id" : "plot",
					"control_id" : "update_data",
					"tab" : "Plot",
					"on_page_load" : False },
				{	"type" : "table",
					"id" : "table_id",
					"control_id" : "update_data",
					"tab" : "Table",
					"on_page_load" : False },
				{	"type" : "html",
					"id" : "html1",
					"control_id" : "update_data",
					"tab" : "Text"}]

	def __init__(self):
		self.upload_data = None
		self.upload_file = None

	def html1(self,params):
		text = "Upload a CSV and press refresh. There's a sample csv in the examples directory that you could try."
		if self.upload_data is not None:
			text = self.upload_data
		return text

	def storeUpload(self,file):
		self.upload_file = file
		self.upload_data = file.read()

	def getData(self, params):
		df = None
		if self.upload_file is not None:
			self.upload_file.seek(0)
			df = pd.read_csv(self.upload_file)
		return df

if __name__ == '__main__':
	app = UserUploadApp()
	app.launch()
{'fraction_non_alphanumeric': 0.14998218738867117, 'fraction_numerical': 0.004987531172069825, 'mean_word_length': 3.16, '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': '6864198', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1016, 'n_words': 270}