Coder Social home page Coder Social logo

codeskyblue / gohttpserver Goto Github PK

View Code? Open in Web Editor NEW
2.5K 56.0 524.0 3.47 MB

The best HTTP Static File Server, write with golang+vue

License: MIT License

Go 21.20% HTML 8.03% JavaScript 54.09% CSS 14.14% Python 1.26% Shell 1.03% Dockerfile 0.22% Procfile 0.04%
go httpserver

gohttpserver's Issues

how to run it on linux as background?

Lots of friends have same issue, I spend 5 hours to figure it out, just share with friends here.

// run it as background

// create file, save to where you call gohttpserver folder.

// create config file

// use nano to edit, or you can create it at windows, use winSCP to copy over
nano supervisord.conf

// type content
[program:supervisord] command=./gohttpserver -r ./fileRestAPI --cors

If you want to save the changes you've made, press Ctrl + O.
To exit nano, type Ctrl + X. If you ask nano to exit from a modified file, it will ask you if you want to save it.
Just press N in case you don't, or Y in case you do. It will then ask you for a filename.
Just type it in and press Enter.

//start supervisord

     supervisord -c supervisord.conf

//stop supervisord
// first switch to root user
sudo su
cd /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver

https://stackoverflow.com/questions/14479894/stopping-supervisord-shut-down
ps -ef | grep supervisord
kill -s SIGTERM 15923 ( only one number a line , line with 2 number are NOT right)
http://supervisord.org/running.html#signals

When you do this:
ps -ef | grep supervisord
//You will get some pid of supervisord just like these

//root 2641 12938 0 04:52 pts/1 00:00:00 grep --color=auto supervisord

//root 29646 1 0 04:45 ? 00:00:00 /usr/bin/python /usr/local/bin/supervisord

if you get output like that, your pid is the second one ( with only one number, it will not change if you run again again, but other number are changing. then if you want to shut down your supervisord you can do this

    kill -s SIGTERM 29646

Here is full supervisord.conf

                     [unix_http_server]
                        file=/tmp/supervisor.sock                       ; path to your socket file


              [supervisord]
              ;logfile=/var/log/supervisord/supervisord.log    ; supervisord log file
              ;logfile_maxbytes=50MB                           ; maximum size of logfile before rotation
              ;logfile_backups=10                              ; number of backed up logfiles
              ;loglevel=error                                  ; info, debug, warn, trace
                ;pidfile=/var/run/supervisord.pid                ; pidfile location
             nodaemon=false                                  ; run supervisord as a daemon
                minfds=1024                                     ; number of startup file descriptors
                minprocs=200                                    ; number of process descriptors
               user=root                                       ; default user
                   ;childlogdir=/var/log/supervisord/               ; where child log files will




                   [program:fileRestAPI]
                  command=./gohttpserver -r ./fileRestAPI --cors
                      ;command=gohttpserver -r ./fileRestAPI --port 8000 --upload --delete --cors


                      [supervisorctl]
                          serverurl=unix:///tmp/supervisor.sock         ; use a unix:// URL  for a unix socket

带中文路径生成二维码,扫描会出现乱码url

修正res/js/index.js
genQrcode: function(text, title) {
var urlPath = this.genInstallURL(text);
var str = urlPath;
var arr = str.split("/");
arr[arr.length - 1] = encodeURI(arr[arr.length - 1]);
var dir = arr.join("/");
$("#qrcode-title").html(title || text);
$("#qrcode-link").attr("href", urlPath);
$('#qrcodeCanvas').empty().qrcode({
text: dir
});
$("#qrcode-modal").modal("show");
},

godep go run main.go or go run main.go

.\main.go:140:8: undefined: NewHTTPStaticServer
.\main.go:170:3: undefined: handleOpenID
怎么打开看看效果
localhost:8000? localhost:8000/testdata?
空白和404

Run on android & ios

Could you provide some releases for windows, linux, mac or android & ios? And also, you can provide a qr code to help mobile phone to visit your file server.

希望加个分享码下载功能哈

增加分享功能,分享就生成一个临时的带有token(有有效期)的url。也可以设置永久token分享。随时可以取消分享。并且提供curl的方式来直接用。

請問如何與 supervisor 整合?

感謝您提供的這個程式,非常簡單好用
不過我在嘗試著用 supervisor去啟動這個程式發生問題

2018/10/18 08:25:25 httpstaticserver.go:111: GET  /home/neonexus/center_yaml
2018/10/18 08:25:25 httpstaticserver.go:749: Hot load index.html
2018/10/18 08:25:25 server.go:2923: http: panic serving 192.168.11.34:43870: open assets/index.html: no such file or directory
goroutine 76 [running]:
net/http.(*conn).serve.func1(0xc420348280)
	/usr/lib/go-1.10/src/net/http/server.go:1726 +0xd0
panic(0x8b0e20, 0xc4204513e0)
	/usr/lib/go-1.10/src/runtime/panic.go:502 +0x229

我用底下的指令,在console下啟動沒有問題,可是丟到 supervisor 啟動就會發生上面的錯誤,找不到 assets 底下的內容?

/usr/local/bin/gohttpserver -r /home/neo/center_yaml/ --port 5000 --upload --delete --debug  --auth-type http --auth-http abc:abc123

文件是否可以按文件名排序?

1、列表中的文件是否可以按文件夹和文件名进行排序?如:似windows的文件资源管理器中的显示。
2、文件夹内的总文件大小不正确(服务端在windows系统平台),有些显示“~ 0 B”实际文件夹内是有文件,且文件是有内容大小不为0B的。

How to setup https(ssl)?

I see your code support https, but I am not sure, how and where,
can you write more details how and where on README?
I know this is go and https question, should not be here,
but since your code already support https, your simple a few words will helps alot.

What I don't know is where to setup gcfg.Cert, gcfg.Key?

I have 2 files "public.cert" and "private.key"
where should I put these 2 files for https,

And does config.yml need to update?
how to connect gcfg.Cert, gcfg.Key to those 2 files?

I also try

    gcfg.Cert = "./public.cert"
gcfg.Key = "./private.key"

and put those 2 files at ./ , failed.

   var err error
if gcfg.Key != "" && gcfg.Cert != "" {
	err = http.ListenAndServeTLS(gcfg.Addr, gcfg.Cert, gcfg.Key, nil)
} else {
	err = http.ListenAndServe(gcfg.Addr, nil)
}
log.Fatal(err)

Configure temp folder

Is there a way to configure the server to use a custom directory instead of /tmp for uploads?

View in Phone产生错误的URL

在本地启动服务,在根目录下点击View in Phone之后地址是这样的http://127.0.0.1:8000/http:/127.0.0.1:8000/

can you add support for Okta ? online authentication

www.okta.com

is a very popular online user management and online authentication, authorization management.

It is have open-id connect supported. ......

If gohttpserver and support okta, then you do NOT need write any code for user management

like sign up, sign in, forget password, retrieve password, reset password, add a new user, assign user a role, role management, etc........ okta can do it for you.

you only need to write a middle ware to connect to okta.

This is best choice for now to add user management to gohttpserver.

Need user login sign up

Anybody can upload? That is huge risk.
Can you add user sign up and user login?
Only logined user can upload!

Add user management is MUST have feature, for it to be useful.
Super admin can disable other user, add, delete other users.

can I search file by name?

I try to search file by file name, (NOT text contend inside file).
I want to find all file name, that have "xxxx", but nothing return.

How to use the search box on top right corner?

Can you wrote some details in READ ME, teach us how to use search function?

rest api feature?

Is it possible add new feature as rest api?

for example:

http://localhost:8000/xxx?f=json

this url will response as a json instead of html.

` {
subfolder: {
{ folder: xxxx1},
{ folder: xxxx1}
},

file: {
{file: yyy1},
{file: yyy2}
.....
}

}`

you also can add other meta data info into this json.

Why do this, is because if you have this rest api, I can write page easy search file name(since all file name, file info are in Json format.)

I mean, you have build the website, if you add rest api for this web site, will be very useful for third party wrote apps to communicate with your site.

For example, twitter rest api, facebook rest api, flickr rest api. etc......

上传文件大于500k 时报 java.net.SocketException: Connection reset by peer: socket write error

        httpClient = HttpClients.custom().setDefaultCredentialsProvider(provider).build();

        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        File file=new File(fileName);
        builder.addBinaryBody("file",file,ContentType.APPLICATION_FORM_URLENCODED,file.getName());

        HttpEntity reqEntity = builder.build();
        httpPost = new HttpPost(serverUrl);
        httpPost.setEntity(reqEntity);
        response = httpClient.execute(httpPost);

how to delete a file?

I know I can upload and download file,

But how to delete a file, I just uploaded?

监听443端口和80端口

自己申请了个证书,然后启动的时候加上证书参数并监听443端口,浏览器直接用https加域名可以访问,但是如果直接域名访问浏览器会默认访问80端口,然后服务器只监听了443端口所以没办法自动跳转到443。能做一个https模式同时监听443和80吗?监听到80有链接就跳到443

file name with '&', failed to load

some time, user just use special char, like &, #, @, etc.... as file name.

then failed to load those files.

Please advice a way to work around?

openid-login.go failed?????

Openid half way working, be able to login into yahoo.com,
but failed when opencallback.......

google openid, does not working.
--auth-openid https://www.google.com/accounts/o8/id

            // google not working
          ./gohttpserver -r ../../../../../fileRestAPI --cors --theme green  --auth-type openid --auth-openid https://www.google.com/accounts/o8/id

yahoo works
--auth-openid https://me.yahoo.com

               // yahoo
              ./gohttpserver -r ../../../../../fileRestAPI --conf ../../../../../fileRestAPI/config.yml --cors --theme green  --auth-type openid --auth-openid https://me.yahoo.com

But, when I successfully login to yahoo.com, when opencallback to gohttpserver, failed.....

                   http://localhost:8000/-/openidcallback?next=https://localhost:8000/&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.return_to=http%3A%2F%2Flocalhost%3A8000%2F-%2Fopenidcallback%3Fnext%3Dhttps%3A%2F%2Flocalhost%3A8000%2F&openid.claimed_id=https%3A%2F%2Fme.yahoo.com%2Fhoogw%23d0256&openid.identity=https%3A%2F%2Fme.yahoo.com%2Fhoogw&openid.assoc_handle=iLcVVWGjabUDODayEuijpKo3jpFxkVv9JI3xrIfcq3PxxWx0Sg3Ye4d7Hnd3BChYXWANhSEYTSfCaMMuaE.V5rDxZt3kSjJvzHtxzC6Qb3MXC3hkDE8fjvwn5jFWbXWIdj4z&openid.response_nonce=2018-12-21T22%3A44%3A55ZLJJRMAiKQCrRV8GGkWoFej0IGqDKnTzG2A--&openid.signed=assoc_handle%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned%2Cpape.auth_level.nist&openid.op_endpoint=https%3A%2F%2Fopen.login.yahooapis.com%2Fopenid%2Fop%2Fauth&openid.pape.auth_level.nist=0&openid.sig=e5FBX8bstv7U9hVukR4r%2BjpDtLs%3D

I test openid-go, sample login on separate port 8080, it successfully login to yahoo.com and back.

If your project use same code as openid-go, why their sample login page work, but this login page only work half way, when opencallback, it fails.......

Can you try this
--auth-openid https://me.yahoo.com

Did you successfully login and back without error?

why search file does not works for me?

I try the demon https://gohttpserver.herokuapp.com

on right top corner, search text box, I type 'readme' it only works one time.

then it stop working.

Then I try type 'image.jpg' in search box right top corner, then nothing. This file is under 'filetypes' folder, why it not find?

Can you advise, why, this happen to me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.