-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted to web app, added docker, makefile, and run.sh
- Loading branch information
Showing
8 changed files
with
148 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM centos:latest | ||
ADD Sohre.repo /etc/yum.repos.d/ | ||
RUN yum install -y patient_csv_to_xml-0.1-1.el7.centos && \ | ||
yum clean all | ||
RUN chgrp -R 0 /opt/patient_csv_to_xml \ | ||
&& chmod -R g+rwX /opt/patient_csv_to_xml | ||
WORKDIR /opt/patient_csv_to_xml | ||
USER patient_csv_to_xml | ||
EXPOSE 8000 | ||
CMD ["/opt/patient_csv_to_xml/patient_csv_to_xml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This expects a few requirements | ||
# one, that https://github.com/Jmainguy/docker_rpmbuild is cloned into ~/Github/docker_rpmbuild | ||
# two, that docker is installed and running | ||
# three, that ~/Github/docker_rpmbuild/dockerbuild/build.sh centos7 has been run | ||
rpm: | ||
@tar -czvf ~/Github/docker_rpmbuild/rpmbuild/SOURCES/patient_csv_to_xml.tar.gz ../patient_csv_to_xml | ||
@cp patient_csv_to_xml.spec ~/Github/docker_rpmbuild/rpmbuild/SPECS/patient_csv_to_xml.spec | ||
@cd ~/Github/docker_rpmbuild/; ./run.sh centos7 patient_csv_to_xml | ||
@ls -ltrh ~/Github/docker_rpmbuild/rpmbuild/RPMS/x86_64/patient_csv_to_xml* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[sohre] | ||
name=Sohre-$releasever | ||
gpgcheck=0 | ||
baseurl=https://pulp.soh.re/pulp/repos/sohre/el$releasever/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
%define _unpackaged_files_terminate_build 0 | ||
%define debug_package %{nil} | ||
Name: patient_csv_to_xml | ||
Version: 0.1 | ||
Release: 1%{?dist} | ||
Summary: A golang http server to convert generations csv to ez claim xml | ||
|
||
License: GPLv2 | ||
URL: https://github.com/Jmainguy/patient_csv_to_xml | ||
Source0: patient_csv_to_xml.tar.gz | ||
|
||
%description | ||
A golang http server to convert generations csv to ez claim xml | ||
|
||
%prep | ||
%setup -q -n patient_csv_to_xml | ||
%build | ||
export GOPATH=/usr/src/go | ||
/usr/bin/go build | ||
%install | ||
mkdir -p $RPM_BUILD_ROOT/opt/patient_csv_to_xml | ||
install -m 0755 $RPM_BUILD_DIR/patient_csv_to_xml/patient_csv_to_xml %{buildroot}/opt/patient_csv_to_xml/ | ||
install -m 0755 $RPM_BUILD_DIR/patient_csv_to_xml/upload.gtpl %{buildroot}/opt/patient_csv_to_xml/ | ||
|
||
%files | ||
/opt/patient_csv_to_xml/patient_csv_to_xml | ||
/opt/patient_csv_to_xml/upload.gtpl | ||
%dir /opt/patient_csv_to_xml | ||
%doc | ||
|
||
%pre | ||
getent group patient_csv_to_xml >/dev/null || groupadd -r patient_csv_to_xml | ||
getent passwd patient_csv_to_xml >/dev/null || \ | ||
useradd -r -g patient_csv_to_xml -d /opt/patient_csv_to_xml -s /sbin/nologin \ | ||
-c "User to run patient_csv_to_xml" patient_csv_to_xml | ||
exit 0 | ||
%post | ||
chown -R patient_csv_to_xml:patient_csv_to_xml /opt/patient_csv_to_xml | ||
|
||
%changelog | ||
* Mon Apr 16 2018 Jonathan Mainguy <jon@soh.re> - 0.1-1 | ||
- Initial release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker run --name patient_csv_to_xml --restart always -p 8000:8000 -d patient_csv_to_xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<html> | ||
<center> | ||
<head> | ||
<title>Upload CSV, Download XML</title> | ||
</head> | ||
<body> | ||
<h1>Upload a CSV file, exported from generations</h1> | ||
<h2>You will get a XML file back, import that into EZ Claim<h2> | ||
<form enctype="multipart/form-data" action="http://localhost:8000/upload" method="post"> | ||
<input type="file" name="uploadfile" /> | ||
<input type="hidden" name="token" value="{{.}}"/> | ||
<input type="submit" value="upload" /> | ||
</form> | ||
</body> | ||
</center> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"io" | ||
"crypto/md5" | ||
"time" | ||
"strconv" | ||
"html/template" | ||
) | ||
|
||
func upload(w http.ResponseWriter, r *http.Request) { | ||
fmt.Println("method:", r.Method) | ||
if r.Method == "GET" { | ||
crutime := time.Now().Unix() | ||
h := md5.New() | ||
io.WriteString(h, strconv.FormatInt(crutime, 10)) | ||
token := fmt.Sprintf("%x", h.Sum(nil)) | ||
|
||
t, _ := template.ParseFiles("upload.gtpl") | ||
t.Execute(w, token) | ||
} else { | ||
r.ParseMultipartForm(32 << 20) | ||
file, _, err := r.FormFile("uploadfile") | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
buffer := convertCsvToXml(file) | ||
|
||
w.Header().Set("Content-Disposition", "attachment; filename=patient.xml") | ||
w.Header().Set("Content-Type", r.Header.Get("Content-Type")) | ||
io.Copy(w, buffer) | ||
} | ||
} |